Guest User

Untitled

a guest
Dec 12th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import os
  2. import errno
  3. import boto3
  4. import botocore
  5.  
  6.  
  7. resource = boto3.resource('s3')
  8. bucket = resource.Bucket('my-bucket')
  9. client = boto3.client('s3')
  10.  
  11. def download_dir():
  12. objList = client.list_objects(Bucket='my-bucket')['Contents']
  13. for obj in objList:
  14. obj_Key = obj['Key']
  15. path,_destPath = os.path.split(obj_Key)
  16. print ("Downloading file :"+ obj_Key);
  17. client.download_file('my-bucket', obj_Key, _destPath)
  18.  
  19. download_dir()
Add Comment
Please, Sign In to add comment