Guest User

Untitled

a guest
Jun 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. aws s3api list-objects-v2
  2. --bucket myBucket
  3. --prefix path1/path2
  4. --query 'reverse(sort_by(Contents,&LastModified))[0]'
  5.  
  6. keys=[]
  7. kwargs = {'Bucket': bucket_name, 'Prefix': key}
  8. while True:
  9. resp = get_conn().list_objects_v2(**kwargs)
  10. keys.append(sorted(response['Contents'], key=lambda item: item['LastModified'])[-1])
  11.  
  12. try:
  13. kwargs['ContinuationToken'] = resp['NextContinuationToken']
  14. except KeyError:
  15. break
  16.  
  17. import boto3
  18.  
  19. client = boto3.client('s3',region_name='ap-southeast-2')
  20.  
  21. response = client.list_objects_v2(Bucket='my-bucket')
  22.  
  23. print (sorted(response['Contents'], key=lambda item: item['LastModified'])[-1])
Add Comment
Please, Sign In to add comment