-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use boto3 #1950
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
Open
Zadigo
wants to merge
47
commits into
django-extensions:main
Choose a base branch
from
Zadigo:use-boto3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Use boto3 #1950
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…er parts of the code
…nderstand what is happening
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi everyone, here is my code proposition to update
sync_s3
to useboto3
in response to the #1876 issue. The reason for this update is mostly technical because when trying to callsync_s3
with the actual code, the logic breaks down under certain conditions. This code proposition withboto3
allows:Opening a connection to S3
One of the main changes occurs in the manner in which a connection is created in order to transfer files to the bucket. Creating a new connection is made via the
Session
class:And uploading by calling
upload_file
on the client:However since we do not know exactly what kind of files are being uploaded, in case the file is large, use memory efficient file processing by taking benefit of multipart upload:
Overriding
s3host
optionAs far as the previous
s3host
option,boto3
usesendpoint_url
parameter in client/resource configuration. So overriding this parameter requires us to use the newsession.Config
class:Variables and settings
Boto3 also requires new settings variables:
AWS_S3_ACCESS_KEY_ID
andAWS_S3_SECRET_ACCESS_KEY
(note the S3) which are breaking changes compared to the previous Boto implementation.AWS_BUCKET_NAME
was renamedAWS_STORAGE_BUCKET_NAME
FILTER_LIST
toAWS_S3_UPLOAD_FILTER_LIST
And the new list of settings would be:
AWS_S3_REGION_NAME
,AWS_S3_ACCESS_KEY_ID
,AWS_S3_SECRET_ACCESS_KEY
,AWS_STORAGE_BUCKET_NAME
,AWS_CLOUDFRONT_DISTRIBUTION
Enhancements
User experience
Now the user understands better what is happening under the hood which also alternatively sticks better with the global Django experience. This obtained essentially by using the internal
self.stdout.write
andself.style
helper functions for commands:Dry Run Mode
Is a new option that was added to allow the user to preview that files that would be uploaded to S3 without actually uploading any files:
I'd be delighted to discuss about these changes 🙂
Next steps
These are some of next steps I think I'm working on moving forward: