Skip to content

Instantly share code, notes, and snippets.

@K-Mistele
Created December 22, 2020 22:28
Show Gist options
  • Select an option

  • Save K-Mistele/c008a2a4bbb85f86d85ceddca9569e36 to your computer and use it in GitHub Desktop.

Select an option

Save K-Mistele/c008a2a4bbb85f86d85ceddca9569e36 to your computer and use it in GitHub Desktop.
An example of uploading and downloading files with the Bucket API
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