Skip to content

[WEB-4316] chore: new endpoints to download an asset#7207

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
chore/asset-download-endpoint
Jun 13, 2025
Merged

[WEB-4316] chore: new endpoints to download an asset#7207
sriramveeraghanta merged 2 commits intopreviewfrom
chore/asset-download-endpoint

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jun 12, 2025

Description

This PR creates 2 new endpoints to download assets.

Type of Change

  • Feature (non-breaking change which adds functionality)

Summary by CodeRabbit

  • New Features
    • Added the ability to download assets directly from both workspace and project levels via new API endpoints. Users can now obtain download links for specific assets within a workspace or project.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

Two new API endpoints were introduced to enable downloading assets at the workspace and project levels. These endpoints generate presigned S3 URLs for asset downloads and were registered in the URL configuration. The corresponding endpoint classes were implemented and imported as needed.

Changes

File(s) Change Summary
apiserver/plane/app/urls/asset.py Added two URL patterns for workspace and project asset download endpoints; imported new endpoint classes.
apiserver/plane/app/views/init.py Imported WorkspaceAssetDownloadEndpoint and ProjectAssetDownloadEndpoint from .asset.v2.
apiserver/plane/app/views/asset/v2.py Added WorkspaceAssetDownloadEndpoint and ProjectAssetDownloadEndpoint classes with GET methods.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Server
    participant S3_Storage

    Client->>API_Server: GET /assets/v2/workspaces/{slug}/download/{asset_id}/
    API_Server->>API_Server: Validate permissions and fetch asset
    API_Server->>S3_Storage: Generate presigned download URL
    S3_Storage-->>API_Server: Return presigned URL
    API_Server-->>Client: Redirect to presigned S3 URL
Loading
sequenceDiagram
    participant Client
    participant API_Server
    participant S3_Storage

    Client->>API_Server: GET /assets/v2/workspaces/{slug}/projects/{project_id}/download/{asset_id}/
    API_Server->>API_Server: Validate permissions and fetch asset
    API_Server->>S3_Storage: Generate presigned download URL
    S3_Storage-->>API_Server: Return presigned URL
    API_Server-->>Client: Redirect to presigned S3 URL
Loading

Suggested labels

ready to merge

Suggested reviewers

  • pablohashescobar
  • NarayanBavisetti
  • Palanikannan1437

Poem

🐇
Two new paths for files to flow,
From workspace or project, off they go!
With presigned links, secure and neat,
Assets hop to users, a download treat.
S3 and endpoints, working in sync—
Rabbits cheer as files unlink!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link

makeplane bot commented Jun 12, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
apiserver/plane/app/views/asset/v2.py (1)

723-755: Avoid copy-pasted endpoint logic

WorkspaceAssetDownloadEndpoint and ProjectAssetDownloadEndpoint are almost identical except for the extra project_id filter.
Extract a small helper (or mix-in) to fetch the asset, run the common checks, and build the presigned URL. This keeps behaviour consistent, removes duplication, and simplifies future maintenance.

🧰 Tools
🪛 Ruff (0.11.9)

724-724: Line too long (96 > 88)

(E501)


740-740: Line too long (96 > 88)

(E501)

🪛 Pylint (3.3.7)

[refactor] 723-723: Too few public methods (1/2)

(R0903)


[refactor] 739-739: Too few public methods (1/2)

(R0903)

apiserver/plane/app/urls/asset.py (1)

94-103: Minor: long lines breach Ruff E501

Lines 95 & 100 exceed 88 chars.
If you adopt the shorter disposition string proposed above this will become moot, otherwise break the arguments onto multiple lines.

apiserver/plane/app/views/__init__.py (1)

110-112: Import block is growing; consider grouping V2 asset endpoints

No functional issue, but the ever-expanding flat import list is getting unwieldy.
Grouping V2 asset endpoints into a dedicated sub-module (e.g. from .asset import v2 as asset_v2) would improve readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad11a34 and 5363c18.

📒 Files selected for processing (3)
  • apiserver/plane/app/urls/asset.py (2 hunks)
  • apiserver/plane/app/views/__init__.py (1 hunks)
  • apiserver/plane/app/views/asset/v2.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apiserver/plane/app/views/__init__.py (1)
apiserver/plane/app/views/asset/v2.py (2)
  • WorkspaceAssetDownloadEndpoint (723-736)
  • ProjectAssetDownloadEndpoint (739-755)
apiserver/plane/app/urls/asset.py (1)
apiserver/plane/app/views/asset/v2.py (2)
  • WorkspaceAssetDownloadEndpoint (723-736)
  • ProjectAssetDownloadEndpoint (739-755)
🪛 Ruff (0.11.9)
apiserver/plane/app/views/asset/v2.py

724-724: Line too long (96 > 88)

(E501)


740-740: Line too long (96 > 88)

(E501)

🪛 Pylint (3.3.7)
apiserver/plane/app/views/asset/v2.py

[refactor] 723-723: Too few public methods (1/2)

(R0903)


[refactor] 739-739: Too few public methods (1/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
apiserver/plane/app/views/asset/v2.py (2)

741-744: Unsafe filename in Content-Disposition header
The header embeds asset.asset.name, which contains the S3 prefix and unescaped characters. This replicates an earlier comment on the same issue. Use the original filename from asset.attributes["name"] (fallback to Path(...).name) and URL-quote it to comply with RFC 6266.


769-771: Unsafe filename in Content-Disposition header
Same issue and fix as the workspace endpoint.

🧹 Nitpick comments (1)
apiserver/plane/app/views/asset/v2.py (1)

740-746: Long line violates Ruff E501 & duplicates code — extract helper
Both download endpoints build the presigned URL in an identical way, and the line length exceeds 88 chars. Factor this into a small utility (e.g., _get_signed_download_url(asset)) to dedupe logic and satisfy linters.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5363c18 and 813f1fd.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/asset/v2.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
apiserver/plane/app/views/asset/v2.py

724-724: Line too long (96 > 88)

(E501)


750-750: Line too long (96 > 88)

(E501)

🪛 Pylint (3.3.7)
apiserver/plane/app/views/asset/v2.py

[refactor] 723-723: Too few public methods (1/2)

(R0903)


[refactor] 749-749: Too few public methods (1/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apiserver/plane/app/views/asset/v2.py (2)

728-734: Prefer .all_objects + explicit filter to ensure soft-deleted rows are ignored

The code relies on the default manager (FileAsset.objects) to hide deleted rows. That assumption leaks the model-level deletion policy into view logic. Use .all_objects and add an explicit deleted_at__isnull=True (or is_deleted=False) filter for robustness and future-proofing.

-            asset = FileAsset.objects.get(
+            asset = FileAsset.all_objects.get(
                 id=asset_id,
                 workspace__slug=slug,
                 is_uploaded=True,
+                deleted_at__isnull=True,
             )

755-761: Repeat of soft-delete concern for project-scoped query

Same reasoning as the workspace variant—use .all_objects plus deleted_at__isnull=True to avoid resurrecting soft-deleted assets when the default manager behavior changes.

@sriramveeraghanta sriramveeraghanta merged commit 6fe0415 into preview Jun 13, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/asset-download-endpoint branch June 13, 2025 09:11
vamsikrishnamathala pushed a commit that referenced this pull request Aug 7, 2025
* refactor: move web utils to packages

* fix: build and lint errors

* chore: update drag handle plugin

* chore: update table cell type to fix build errors

* fix: build errors

* chore: sync few changes

* feat: add pi base url to constants

* chore: update all util imports in ee folder

* chore: refactor web utils imports

* chore: update imports

* fix: build errors

* fix: build errors

* fix: update utils import

* chore: minor fixes related to duplicate assets imports

* chore: update duplicate assets service

* [WEB-4316] chore: new endpoints to download an asset (#7207)

* chore: new endpoints to download an asset

* chore: add exception handling

* [WEB-4323] refactor: Analytics refactor (#7213)

* chore: updated label for epics

* chore: improved export logic

* refactor: move csvConfig to export.ts and clean up export logic

* refactor: remove unused CSV export logic from WorkItemsInsightTable component

* refactor: streamline data handling in InsightTable component for improved rendering

* feat: add translation for "No. of {entity}" and update priority chart y-axis label to use new translation

* refactor: cleaned up some component and added utilitites

* feat: add "at_risk" translation to multiple languages in translations.json files

* refactor: update TrendPiece component to use new status variants for analytics

* fix: adjust TrendPiece component logic for on-track and off-track status

* refactor: use nullish coalescing operator for yAxis.dx in line and scatter charts

* feat: add "at_risk" translation to various languages in translations.json files

* feat: add "no_of" translation to various languages in translations.json files

* feat: update "at_risk" translation in Ukrainian, Vietnamese, and Chinese locales in translations.json files

* refactor: rename insightsFields to ANALYTICS_INSIGHTS_FIELDS and update analytics tab import to use getAnalyticsTabs function

* feat: update AnalyticsWrapper to use i18n for titles and add new translation for "no_of" in Russian

* fix: update yAxis labels and offsets in various charts to use new translation key and improve layout

* feat: define AnalyticsTab interface and refactor getAnalyticsTabs function for improved type safety

* fix: update AnalyticsTab interface to use TAnalyticsTabsBase for improved type safety

* fix: add whitespace-nowrap class to TableHead for improved header layout in DataTable component

* [WEB-4311]  fix: membership data handling and state reversal on error (#7205)

* [WEB-4231] Pie chart tooltip #7192

* fix: build errors

* fix: utils imports

* chore: fix build errors

* yarn lock file update

---------

Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com>
Co-authored-by: JayashTripathy <76092296+JayashTripathy@users.noreply.github.com>
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* chore: new endpoints to download an asset

* chore: add exception handling
@coderabbitai coderabbitai bot mentioned this pull request Aug 28, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants