I’m trying to list objects in my Spaces bucket:
session = boto3.session.Session()
s3_client = session.client('s3',
region_name='blr1',
endpoint_url=my_endpoint_url,
)
response = client.list_objects_v2(Bucket=my_spaces_name)
I keep getting the error: Error: An error occurred (NotImplemented) when calling the ListObjectsV2 operation: Server does not support one or more requested headers.
When I check the documentation it says v2 is supported. Even dropping the v2 doesn’t change the nature of the error. Any help welcome.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi,
It looks like you’re using client
instead of s3_client
when calling the list_objects_v2
method. Update your code to use the correct variable name:
session = boto3.session.Session()
s3_client = session.client('s3',
region_name='blr1',
endpoint_url=my_endpoint_url,
)
response = s3_client.list_objects_v2(Bucket=my_spaces_name)
print(response)
Also, make sure your endpoint_url
is correctly set to something like https://blr1.digitaloceanspaces.com
.
- Bobby
Heya,
something like the following should work for you
session = boto3.session.Session()
s3_client = session.client('s3',
region_name='blr1',
endpoint_url=my_endpoint_url,
)
response = s3_client.list_objects(Bucket=my_spaces_name)
if 'Contents' in response:
for obj in response['Contents']:
print(obj['Key'])
else:
print("No objects found or listing is not supported")
As said you need to use s3_client
.
Heya, @qumata
You can use s3cmd
as an alternative to list objects in your Spaces bucket.
s3cmd
sudo apt install s3cmd
Or via pip:
pip install s3cmd
s3cmd
for DigitalOcean Spacess3cmd --configure
Set these values:
blr1
https://blr1.digitaloceanspaces.com
s3v4
s3cmd ls s3://your-bucket-name/
s3cmd ls --recursive s3://your-bucket-name/
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.