Created
December 22, 2020 22:28
-
-
Save K-Mistele/c008a2a4bbb85f86d85ceddca9569e36 to your computer and use it in GitHub Desktop.
An example of uploading and downloading files with the Bucket API
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
| import s3_bucket as S3 | |
| import os | |
| # get your key data from environment variables | |
| AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') | |
| AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') | |
| # initialize the package | |
| S3.Bucket.prepare(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) | |
| # initialize a bucket | |
| my_bucket = S3.Bucket('my-bucket') | |
| # UPLOAD A FILE | |
| my_bucket.upload_file('/tmp/file_to_upload.txt', 'myfile.txt') | |
| my_bucket.download_file('myfile.txt', '/tmp/destination_filename.txt') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment