从S3存储桶中使用boto3读取文件内容。

9 浏览
0 Comments

从S3存储桶中使用boto3读取文件内容。

我通过以下方式读取我的S3存储桶中的文件名:

objs = boto3.client.list_objects(Bucket='my_bucket')
    while 'Contents' in objs.keys():
        objs_contents = objs['Contents']
        for i in range(len(objs_contents)):
            filename = objs_contents[i]['Key']

现在,我需要获取文件的实际内容,类似于 open(filename).readlines()。有什么最佳方法?

0