Issue
How to get a list of all the filenames present in the s3 bucket.
import boto3
import pandas as pd
s3 = boto3.client('s3')
s3 = boto3.resource( service_name='s3', region_name='us',
aws_access_key_id='pjh', aws_secret_access_key='mm')
ob = []
for i in s3.Bucket('xyzbucket').objects.all():
ob.append(i)
test= []
for i in ob:
test.append(i['Contents']['key'])
TypeError: 's3.ObjectSummary' object is not subscriptable
Solution
It should be:
test.append(i.key)
not
test.append(i['Contents']['key'])
Answered By - Marcin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.