support space
mm580486 opened this issue · 5 comments
hi search about space api on droplet kit gem but i cant find anything , please add this api to droplet_kit gem
thanks
Hi @mm580486, for that you can use any S3 client, we don't have plans right now to introduce spaces to droplet_kit given you can use any S3 client for it.
you can paste a sample code for upload on digital ocean space (only upload ) ? i can develop another action if you help to me
Spaces was designed to be compatible with AWS S3 so that people can take advantage of the existing ecosystem of tools. In most cases, all you need to do is configure the endpoint
value to point to "https://nyc3.digitaloceanspaces.com" For example, here are some basic operations with Spaces using the AWS Ruby SDK:
require 'aws-sdk-s3'
# Configure client for use with Spaces
client = Aws::S3::Client.new(
access_key_id: 'ACCESS_KEY',
secret_access_key: 'SECRET_KEY',
endpoint: 'https://nyc3.digitaloceanspaces.com',
region: 'nyc3'
)
# Create a new Space
client.create_bucket({
bucket: "my-new-space-with-a-unique-name",
acl: "private"
})
# List all Spaces
spaces = client.list_buckets()
spaces.buckets.each do |space|
puts "Name: #{space.name}\t\tCreated: #{space.creation_date}"
end
# Add a file to a Space
resp = client.put_object({
body: "The contents of the file",
bucket: "my-new-space-with-a-unique-name",
key: "file-name.txt"
})
puts "Object uploaded:\n #{resp.to_h}"
Hope that helps! If you have more specific questions, feel free to ask over on the DigitalOcean community site: https://www.digitalocean.com/community/questions
i tested this code and works fine , and i have a question how to set other properties like permission file and upload directory ( i have three directory on space like instagram , youtube and ... )
@mm580486 the best place to ask that is at https://www.digitalocean.com/community/questions