Skip to content

Instantly share code, notes, and snippets.

@yamyamyuo
Created October 11, 2018 06:03
Show Gist options
  • Save yamyamyuo/ca8078e863fcfc16395899f08d8f2677 to your computer and use it in GitHub Desktop.
Save yamyamyuo/ca8078e863fcfc16395899f08d8f2677 to your computer and use it in GitHub Desktop.
AWS S3 code
# 找到某个bucket 下, 限定prefix下, 所有的key
import os
import boto3
bucket_name = 'tmp-bucket'
_s3 = boto3.resource('s3',region_name='cn-north-1')
print _s3
bucket = _s3.Bucket(bucket_name)
print bucket.name
all_objects = _s3.meta.client.list_objects(Bucket = bucket_name)
a = list(bucket.objects.filter(Prefix='sqlbuffet/c1f28d4c-6a22-11e8-b107-0286059f4ff3'))
for i in a:
print i.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment