Advertisement
andrewb

dl.py

Jun 26th, 2016
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import urllib3, sys, boto3
  2.  
  3. bucket_name = sys.argv[2]
  4. url = sys.argv[1]
  5. file = url.split('/')[-1:][0]
  6. ext = file.split('.')[-1:][0]
  7.  
  8. http = urllib3.PoolManager(cert_reqs=None)
  9. r = http.request('GET', url)
  10.  
  11. with open(file, 'wb') as the_file:
  12.     the_file.write(r.data)
  13.  
  14. s3 = boto3.client('s3')
  15. s3.upload_file(file, bucket_name, file,
  16.                ExtraArgs={'ACL': 'public-read',
  17.                           'ContentType':'image/'+ext})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement