By tarunsinghal
I am trying to automated some of my task related to digialocean spaces. but stuck at when i a trying to upload an object to spaces. and i also want to know is there any way to set expiration tag on the object.
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!
Check this out simple script to help manage your spaces and droplets in python https://github.com/Mashoud123/digitalocean-python-manager
To answer the second question first, Spaces does not currently support “lifecycle” events. So unfortunately you can not use expiration tags at this time.
For the question in the title, uploading an object to Spaces using boto3 requires that you edit the endpoint setting for the session. Here’s a quick example:
import boto3
session = boto3.session.Session()
client = session.client('s3',
region_name='nyc3',
endpoint_url='https://nyc3.digitaloceanspaces.com',
aws_access_key_id='ACCESS_KEY',
aws_secret_access_key='SECRET_KEY')
client.upload_file('/path/to/file.ext', # Path to local file
'my-space', # Name of Space
'file.ext') # Name for remote file
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.