-
Notifications
You must be signed in to change notification settings - Fork 13
Enable AWS S3 image storage : Issue #208 #320
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
Conversation
91fc5d1
to
29f065a
Compare
29f065a
to
73b7b81
Compare
src/shared/static/static.service.ts
Outdated
private readonly MAX_DISK_USAGE: number = parseInt(process.env.MAX_TEMP_STORAGE_FOR_S3_DOWNLOAD) * 1 * 1024 * 1024; | ||
private s3Client: S3Client; | ||
|
||
private readonly DELETE_INTERVAL = 60 * 60 * 1000; // Check for deletions every hour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move clean up logic to TasksService
mb make sense to extract this to another PR? guess this could be great project setting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's do it via another PR.
0e14ade
to
df7916b
Compare
c7f528e
to
080c07c
Compare
|
||
@Get('/:fileName') | ||
@ApiOkResponse() | ||
async downloadPngAndRedirect(@Param('fileName') fileName: string, @Res() res: Response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why we need controller for this purpose
could frontend get the image by direct url?
think I don't understand why we need to save file locally and than delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for merge conflicts
I did prepare code for another static provider
could you move this implementation here?
existing code ideally would not be changed and we could write new e2e tests
https://github.com/Visual-Regression-Tracker/backend/blob/master/src/static/aws/s3.service.ts
8564b28
to
d2f18d7
Compare
Thanks for incorporating changes to support multiple image storage. I have pushed code which does the following
|
src/static/static.controller.ts
Outdated
const AWS_REGION = process.env.AWS_REGION; | ||
const AWS_S3_BUCKET_NAME = process.env.AWS_S3_BUCKET_NAME; | ||
|
||
const s3Client = new S3Client({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this logic to service layer like getImageUrl
for both hdd and s3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This is based on the issue #208. Integrated AWS S3 bucket for image storage. To use this feature, change the backend .env file to include below details
Also, add the line in the front end (another pull request will be added to the front end to support it once this pull request is merged.) .env file
USE_AWS_S3_BUCKET=true
Add the line to
env.config.ts
file also to support reading of this new env entry.Change the frontend static.service.ts getImage function as below
The image will be stored like below.

A few important notes on the implementation: