@sam I did the research and yes, this is well supported by aws-sdk-ruby even though the documentation is lacking. This is a demonstration of aws-sdk-ruby being used to upload an archive to DigitalOcean Spaces. This works really well and I hope this helps and gives everyone an idea about how compatible these services are.
Steps:
- Create a DigitalOcean Space.
- Generate Access Keys for your DigitalOcean Account.
- Paste the Space name (bucket), key pair (access_key_id, secret_access_key), file name and path in the variables below. Run the code and the file should be visible in your Space.
require 'aws-sdk-s3'
name = 'test.tar.gz'
path = '/home/workspace/test.tar.gz'
# Before uploading, ensure that you've created a Space on DigitalOcean
bucket = 'discoursetest1'
# Configure an S3 Resource for use with Spaces
# Note: Generate Spaces Access Keys from cloud.digitalocean.com/settings/api/
s3 = Aws::S3::Resource.new(
access_key_id: '',
secret_access_key: '',
endpoint: 'https://nyc3.digitaloceanspaces.com',
region: 'nyc3',
)
# Add a file to a Space
obj = s3.bucket(bucket).object(name)
obj.upload_file(path)
Note:
Read more about DigitalOcean’s AWS S3 compatiblity here and the AWS Ruby SDK here.