I have created a space and then the folder inside the space to store mp3 files. I would like to access all the files stored in the folder programaticallty. Is there any index.html file created for every folder content? Or How would I access the files stored in​ the folder?

I have tried https://spacename.nyc3.digitaloceanspaces.com/, which list all the files and folders (permission is set to Public)

But when is there some URL, https://spacename.nyc3.digitaloceanspaces.com/folder-name/ to access the files inside the particular folder?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

In order to be compatible with existing tools, the Spaces API was designed to be inter-operable with the S3 API. With S3, there is no real concept of a folder. When you create a “folder” through the Spaces UI, it is actually just a “key” with a zero sized “object.” Items inside the folder have the folder key as a prefix to their own key.

For example, here is a listing of objects in a Space with a folder named foo containing a file named bar using the aws cli:

$ aws s3api --endpoint-url https://nyc3.digitaloceanspaces.com --profile do list-objects --bucket my-bucket
    "Contents": [
            "LastModified": "2017-10-17T17:50:50.840Z", 
            "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"", 
            "StorageClass": "STANDARD", 
            "Key": "foo/", 
            "Owner": {
                "DisplayName": "681451698", 
                "ID": "681451698"
            "Size": 0
            "LastModified": "2017-10-17T17:56:08.583Z", 
            "ETag": "\"8cf8463b34caa8ac871a52d5dd7ad1ef\"", 
            "StorageClass": "STANDARD", 
            "Key": "foo/bar", 
            "Owner": {
                "DisplayName": "681451698", 
                "ID": "681451698"
            "Size": 2

You can programmatically list the contents of a “folder” by including a prefix query parameter when calling the API to list the contents of a Space. Here’s a quick Python 3 example:

import boto3

session = boto3.session.Session()
client = session.client('s3',

resp = client.list_objects(Bucket='my-bucket', Prefix='foo/')
for obj in resp['Contents']:
  • Hi, I have tried the boto3 code that you provided. So client.get_object gives me the file as a response but both

    • client.list_objects(Bucket=bucket) and
    • client.list_objects_v2(Bucket=bucket)

    yield NoSuchKey: An error occurred (NoSuchKey) when calling the ListObjects operation: Unknown

    Any thoughts on what’s going on?

  • this however only works for the first 1000 objects as list_objects returns 1000 objects max. What is the pattern if I have buckets with more than 1000 objects?

Submit an Answer