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

[Issue 2512] S3 Presign URL #2563

Merged
merged 40 commits into from
Oct 30, 2024
Merged

[Issue 2512] S3 Presign URL #2563

merged 40 commits into from
Oct 30, 2024

Conversation

babebe
Copy link
Collaborator

@babebe babebe commented Oct 24, 2024

Summary

Fixes #{2512}

Time to review: 20 mins

Changes proposed

Added test files for opportunity attachment
Updated local seed db with func to upload test files to S3
Updated factories to set opportunity attachment "file_location" from any value in static list
Updated the response schema to return new field download_path which is the link to the pre-signed url
Added default Expiration limit for the s3 url in s3 config
Added reusable function to get aws boto3 session for local development
Added new env variable for local development
Added fixture to upload test files
Added unit test. Tests if we can successfully download s3 file.

Context for reviewers

Return a pre-signed url for an attachment a user can then use to download the s3 file

Additional information

Screenshots, GIF demos, code examples or output to help show the changes working as expected.

@babebe babebe added the draft Not yet ready for review label Oct 24, 2024
@babebe babebe marked this pull request as draft October 24, 2024 14:54
@babebe babebe requested a review from chouinar October 28, 2024 15:38
@babebe babebe linked an issue Oct 28, 2024 that may be closed by this pull request
3 tasks
api/src/adapters/aws/s3_adapter.py Outdated Show resolved Hide resolved
api/src/services/opportunities_v1/get_opportunity.py Outdated Show resolved Hide resolved
api/src/services/opportunities_v1/get_opportunity.py Outdated Show resolved Hide resolved
@babebe babebe removed the draft Not yet ready for review label Oct 29, 2024
@babebe babebe requested a review from chouinar October 29, 2024 14:57
@babebe babebe marked this pull request as ready for review October 29, 2024 14:57
Copy link
Collaborator

@chouinar chouinar left a comment

Choose a reason for hiding this comment

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

Looks good, tested it locally, just a few tidying up suggestions

api/src/api/opportunities_v1/opportunity_schemas.py Outdated Show resolved Hide resolved
api/src/services/opportunities_v1/get_opportunity.py Outdated Show resolved Hide resolved
api/src/services/opportunities_v1/get_opportunity.py Outdated Show resolved Hide resolved
api/tests/lib/seed_local_db.py Outdated Show resolved Hide resolved
Comment on lines 65 to 68
if s3_config.s3_endpoint_url:
pre_sign_file_loc = pre_sign_file_loc.replace(
s3_config.s3_endpoint_url, "http://localhost:4566"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest we add a comment calling out this hacky fix as only mattering locally due to docker path issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should i mark it as todo as well ?

@babebe babebe requested a review from chouinar October 30, 2024 14:16
Copy link
Collaborator

@chouinar chouinar left a comment

Choose a reason for hiding this comment

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

LGTM!

@babebe babebe merged commit f1fa121 into main Oct 30, 2024
8 checks passed
@babebe babebe deleted the 2512-s3-presign-url branch October 30, 2024 16:42
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.

Setup presigning the URLs for opportunity attachments
3 participants