Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list all items in digital ocean spaces

import boto3
from botocore.client import Config

# Initialize a session using DigitalOcean Spaces.
session = boto3.session.Session()
client = session.client('s3',
                        region_name='fra1',
                        endpoint_url='https://fra1.digitaloceanspaces.com',
                        aws_access_key_id= ACCESS_KEY_ID,
                        aws_secret_access_key=SECRET_ACCESS_KEY)

# List all buckets on your account.
response = client.list_buckets()
spaces = [space['Name'] for space in response['Buckets']]
print("Spaces List: %s" % spaces)

# Print all items in a bucket
response = client.list_objects(Bucket='bucket-name')
for obj in response['Contents']:
    print(obj['Key'])
Source by docs.digitalocean.com #
 
PREVIOUS NEXT
Tagged: #list #items #digital #ocean #spaces
ADD COMMENT
Topic
Name
3+7 =