Created
October 11, 2018 06:03
-
-
Save yamyamyuo/ca8078e863fcfc16395899f08d8f2677 to your computer and use it in GitHub Desktop.
AWS S3 code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 找到某个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