Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import boto3
  2.  
  3. def upload_file( filename ):
  4. session = boto3.Session()
  5. s3_client = session.client( 's3' )
  6.  
  7. try:
  8. print "Uploading file:", filename
  9.  
  10. tc = boto3.s3.transfer.TransferConfig()
  11. t = boto3.s3.transfer.S3Transfer( client=s3_client,
  12. config=tc )
  13.  
  14. t.upload_file( filename, 'my-bucket-name', 'name-in-s3.dat' )
  15.  
  16. except Exception as e:
  17. print "Error uploading: %s" % ( e )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement