-
Notifications
You must be signed in to change notification settings - Fork 449
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: upload image to aws s3 #200
Conversation
Please send PRs only to approved issues. |
@isabelcosta @ramitsawhney27 I've opened a Pr reagrding the upload of image in amazon s3 for the issue #152 |
2e4af22
to
d812dbd
Compare
e1ac1b6
to
ca69d2d
Compare
@ramitsawhney27 @agarwalrounak I've updated the PR. |
ca69d2d
to
704f8fa
Compare
b9811f8
to
707e87a
Compare
@ramitsawhney27 I've updated the PR with the changes and removed the merge conflict. |
@CleverFool77 uploading an image is testable on Postman? I have to try this. Thank you so much for the work you're doing here. |
@isabelcosta Yes we can test it on Postman.
|
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.
@CleverFool77 I left two comments. I haven't got the time to test this feature yet. Once I do, I'll give you a complete review
@m-murad we have to setup these (e.g.: AWS_ACCESS_KEY and etc) on TravisCI right? |
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.
@CleverFool77 I'm ok with this after you make the changes I requested ;)
707e87a
to
65334a2
Compare
Hi @isabelcosta I've updated the PR as requested. |
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.
@CleverFool77 left a comment for a typo. It's almost done ;)
app/api/dao/user.py
Outdated
if 'photo_url' in data and data['photo_url']: | ||
image_type = data['photo_url'].split(';')[0].split('/')[1] | ||
image_name = ".".join((username, image_type)) | ||
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.congif["AWS_PROFILE_BUCKET"], image_name) |
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.
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.congif["AWS_PROFILE_BUCKET"], image_name) | |
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.config["AWS_PROFILE_BUCKET"], image_name) |
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.
Updated .
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.
@CleverFool77 this doesn't appear to be changed. Maybe it happened something when you squashed the commits. Can you please change that.
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.congif["AWS_PROFILE_BUCKET"], image_name) | |
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.config["AWS_PROFILE_BUCKET"], image_name) |
65334a2
to
c746346
Compare
Hi @isabelcosta |
@CleverFool77 thank you so much for your contribution and patience! Well done! 🎉 I'm not sure when I will merge this because I haven't figure out yet if it's better to set up the environments to the AWS Systers uses, or not. I'm also analyzing the volatile database issue and where data will be stored, and all of this thinking about the development environment. Your work here is done, just wanted to let you know where I'm at. There's also the possibility of merging this without the environment variables set, and all run ok. I have to test this, yet. Once I do, if all goes well I can merge right away. |
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.
@CleverFool77 left some comments because of something I noticed on the Travis CI current configuration.
Let me know if you need any clarification.
config.py
Outdated
@@ -14,6 +14,11 @@ class BaseConfig(object): | |||
JWT_ACCESS_TOKEN_EXPIRES = timedelta(weeks=1) | |||
JWT_REFRESH_TOKEN_EXPIRES = timedelta(weeks=4) | |||
|
|||
# Aws details | |||
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID') |
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.
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID') | |
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_ID') |
Can you please change the expected environment variable to AWS_ACCESS_ID
. I'm saying this because during the Community Open Session with @mayburgos and @m-murad that Travis CI has that variable like AWS_ACCESS_ID
instead of AWS_ACCESS_KEY_ID
.
app/api/dao/user.py
Outdated
if 'photo_url' in data and data['photo_url']: | ||
image_type = data['photo_url'].split(';')[0].split('/')[1] | ||
image_name = ".".join((username, image_type)) | ||
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.congif["AWS_PROFILE_BUCKET"], image_name) |
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.
@CleverFool77 this doesn't appear to be changed. Maybe it happened something when you squashed the commits. Can you please change that.
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.congif["AWS_PROFILE_BUCKET"], image_name) | |
photo_url = aws_upload.upload_to_aws(data['photo_url'], application.config["AWS_PROFILE_BUCKET"], image_name) |
Thanks @isabelcosta for the review. |
c746346
to
bf20acd
Compare
Hii @isabelcosta !! Thanks !!! |
@CleverFool77 hey can you please solve the merge conflicts ? Thanks! |
@CleverFool77 closing the PR due to inactivity , thank you for your contribution :) |
@vj-codes thank you for closing this. At the moment we don't have access to AWS S3 so this wouldn't be merged so soon. We'll reopen if the situation changes. |
Description
Fixes #152
Server will be getting an encoded string of image as input,The image will be decoded and uploaded on aws s3. Then aws s3 url of the image will be saved in the db field of user's photo_url. A new api endpoint to return the user's profile picture is created.
The testing has been done in my own aws s3 bucket. Three environment variables
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
andAWS_PROFILE_BUCKET
are created. The username is taken as image name to avoid multiple images of user.I've extracted the image extension from the encoded string input (uploaded from frontend).
It's assumed that the frontend encodes the image in base64 encoding.
Type of Change:
Delete irrelevant options.
Code/Quality Assurance Only
How Has This Been Tested?
This has been tested using postman.
Checklist:
Delete irrelevant options.
Code/Quality Assurance Only