Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add endpoint for uploading assets #2130

Merged
merged 11 commits into from
Feb 26, 2025
Merged

feat: Add endpoint for uploading assets #2130

merged 11 commits into from
Feb 26, 2025

Conversation

gzurowski
Copy link
Member

@gzurowski gzurowski commented Feb 25, 2025

Allows to create presigned URLs for uploading assets (PDF, JPEG, PNG) for comments, notes and papers.

Example request:

curl --request POST \
  --url http://localhost:8000/api/asset/upload/ \
  --header 'content-type: multipart/form-data' \
  --form filename=test.pdf \
  --form content_type=application/pdf \
  --form entity=paper

Example response:

{
  "presigned_url": "https://researchhub-dev-storage.s3.amazonaws.com/uploads/papers/users/3/b48f890a-ae44-46f7-832a-7d783f009111/test.pdf?[...]&Expires=1740507772",
  "object_key": "uploads/papers/users/3/b48f890a-ae44-46f7-832a-7d783f009111/test.pdf",
  "object_url": "https://storage.dev.researchhub.com/uploads/papers/users/3/b48f890a-ae44-46f7-832a-7d783f009111/test.pdf"
}

The presigned_url is the URL the client needs to upload the file using a PUT request.
The object_url is the final URL of the uploaded file.

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.82%. Comparing base (538c7eb) to head (2fe20d1).
Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2130      +/-   ##
==========================================
+ Coverage   67.77%   67.82%   +0.05%     
==========================================
  Files         427      431       +4     
  Lines       23586    23627      +41     
==========================================
+ Hits        15985    16026      +41     
  Misses       7601     7601              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Replaced by S3StorageService in `researchhub` package.
@gzurowski gzurowski changed the title Add storage service for uploading assets feat: Add storage service for uploading assets Feb 25, 2025
@gzurowski gzurowski changed the title feat: Add storage service for uploading assets feat: Add endpoint for uploading assets Feb 25, 2025
@gzurowski gzurowski marked this pull request as ready for review February 25, 2025 18:28
@gzurowski gzurowski requested a review from a team as a code owner February 25, 2025 18:28
@gzurowski gzurowski merged commit 1be6a83 into master Feb 26, 2025
5 checks passed
@gzurowski gzurowski deleted the storage-service branch February 26, 2025 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants