Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
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.
Accepted Answer
The API that the Spaces dashboard calls is an internal implementation detail. It’s how our Ember front end talks to our backend. Under the hood, it is still accessing the same S3-compatible API from the linked docs.
A “folder” 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:
$ 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
}
]
}
The API does not support recursively deleting files per se. On the backend, we list all objects with that prefix and then delete them. You can achieve this same result by including a prefix query parameter when calling the API to list the contents of a Space. Here’s a quick Python example:
import boto3
session = boto3.session.Session()
client = session.client('s3',
region_name='nyc3',
endpoint_url='https://nyc3.digitaloceanspaces.com',
aws_access_key_id='ACCESSKEY',
aws_secret_access_key='SECRETKEY')
resp = client.list_objects(Bucket='my-bucket', Prefix='foo/')
objects_to_delete = []
for obj in resp['Contents']:
objects_to_delete.append({'Key': obj['Key']})
response = client.delete_objects(Bucket='my-bucket',
Delete={
'Objects': objects_to_delete
})
print("Deleted: {0}".format(response['Deleted']))
Hope that helps!