frzkazmi

do_upload.py

May 16th, 2021
524
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import boto3
  2.  
  3. aws_access_key_id = ''
  4. aws_secret_access_key = ''
  5.  
  6. def upload_file(local_path, bucket_name, s3_path):
  7.     session = boto3.session.Session()
  8.     client = session.client('s3',
  9.                         region_name='fra1',
  10.                         endpoint_url='https://fra1.digitaloceanspaces.com',
  11.                         aws_access_key_id=aws_access_key_id,
  12.                         aws_secret_access_key=aws_secret_access_key)
  13.  
  14.     client.upload_file(local_path, bucket_name, s3_path, ExtraArgs={'ACL':'public-read'})
RAW Paste Data