External Storage / DigitalOcean Spaces
To use DigitalOcean Spaces as your External Storage of choice, you must set the provider
attribute to digitalocean
within the store
hash and, at a minimum, provide your DigitalOcean Spaces credentials (key
and secret
) as well as a bucket
name and the DigitalOcean Spaces region
where your bucket is located. The full list of store
hash attibutes for DigitalOcean Spaces can be found below.
Alternatively, you can use our Secure Storage Connectors. Simply save your credentials in your Optidash Account and reference them by ID. This mechanism significantly enhances the security of your cloud credentials. When Secure Storage Connectors are in use, you only need to provide the Optidash API with your Connector id
instead of provider
, key
, and secret
properties. You can add a new Connector in your Optidash Account.
Authentication
When passing DigitalOcean Spaces credentials in your request JSON, you have to set the following authentication properties:
Attribute | Type | Description |
provider |
String | provider must be set to digitalocean |
key |
String | DigitalOcean Spaces Key Id |
secret |
String | DigitalOcean Spaces Secret Access Key |
{
"store": {
"provider": "digitalocean",
"key": "your-digitalocean-key",
"secret": "your-digitalocean-secret"
}
}
When using Secure Storage Connectors, you only need to provide your Connector ID:
Attribute | Type | Description |
id |
String | Secure Storage Connector ID |
{
"store": {
"id": "your-connector-id"
}
}
DigitalOcean Spaces properties and settings
Attribute | Type | Required | Description |
bucket |
String | Yes | Name of a destination bucket in your DigitalOcean Spaces. |
region |
String | Yes | Name of the DigitalOcean Spaces Region in which your S3 bucket is located. |
path |
String | No | Destination path in your DigitalOcean Spaces bucket (without leading slash). Defaults to root. |
acl |
String | No | The Access Control List of the destination object. Defaults to public-read . |
metadata |
Hash | No | Custom metadata. |
headers |
Hash | No | Custom HTTP headers. |
The Optidash API allows you to set the following custom headers on your objects: Cache-Control
, Content-Type
, Content-Encoding
and Content-Disposition
.
{
"store": {
"provider": "digitalocean",
"key": "your-digitalocean-key",
"secret": "your-digitalocean-secret",
"bucket": "images",
"region": "your-digitalocean-region",
"path": "assets/image.jpg",
"acl": "public-read",
"metadata": {
"key": "value"
},
"headers": {
"Cache-Control": "max-age=2592000000"
}
}
}
An example cURL request of using DigitalOcean Spaces as External Storage provider will look like the following:
curl https://api.optidash.ai/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.website.com/image.jpg",
"resize": {
"width": 100,
"height": 75
},
"store": {
"provider": "digitalocean",
"key": "your-digitalocean-key",
"secret": "your-digitalocean-secret",
"bucket": "images",
"region": "fra1",
"path": "assets/image.jpg",
"headers": {
"Cache-Control": "max-age=2592000000"
}
}
}'
When using DigitalOcean Spaces as your External Storage, the url
property within the JSON response will point to the object's location within the DigitalOcean Space and you can safely use that URL in production, for example:
HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json
{
"success": true,
"code": 200,
"id": "9fccf4b5-cfab-4e92-9276-5d2028fcb6a0",
"input": {
"name": "image.jpg",
..
},
"output": {
"url": "https://bucket-name.fra1.digitaloceanspaces.com/assets/image.jpg",
..
}
}