Created
December 22, 2020 22:29
-
-
Save K-Mistele/9832da95d0e31783de5ab330269eebfd to your computer and use it in GitHub Desktop.
Example of storing large blobs of data 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') | |
| # some json string | |
| my_json_str = "{'a': 1, 'b': 2}" # an example json string | |
| my_bucket.put('json_data_1', my_json_str) | |
| data, metadata = my_bucket.get('json_data_1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment