Skip to content

Instantly share code, notes, and snippets.

@claudijd
Created November 15, 2019 18:00
Show Gist options
  • Save claudijd/c77cf95a205f4a9d83f0ab8ebb6dfd3a to your computer and use it in GitHub Desktop.
Save claudijd/c77cf95a205f4a9d83f0ab8ebb6dfd3a to your computer and use it in GitHub Desktop.
boto => boto3 file upload
# In boto
import boto
conn = boto.connect_s3(aws_access_key_id=aws_access_key_id,aws_secret_access_key=aws_secret_access_key)
bucket = conn.get_bucket(bucket_name, validate=False)
key = boto.s3.key.Key(bucket)
key.key = key_name
key.set_contents_from_filename(file_path)
url = "https://{}.s3.amazonaws.com/{}".format(bucket.name, key.name)
# In boto3
import boto3
s3_client = boto3.client(
's3',
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key
)
s3_client.upload_file(file_path, bucket_name, key_name)
url = "https://{}.s3.amazonaws.com/{}".format(bucket_name, key_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment