For AI agents: The documentation index is at https://docs.digitalocean.com/llms.txt. Markdown versions of pages use the same URL with index.html.md in place of the HTML page (for example, append index.html.md to the directory path instead of opening the HTML document).
Use DigitalOcean Spaces with AWS S3 SDKs
Last verified 22 Jun 2026
Spaces Object Storage is an S3-compatible service for storing and serving large amounts of data. The built-in Spaces CDN minimizes page load times, improves performance, and reduces bandwidth and infrastructure costs.
The Spaces API is compatible with the AWS S3 API, so you can use many existing S3 tools and libraries with Spaces. One common use case is managing Spaces buckets programmatically with AWS S3 software development kits (SDKs).
AWS provides S3 SDKs for a variety of languages, and many of them are compatible with the Spaces API. For more information about Spaces compatibility with the S3 API, see the Spaces API documentation.
In S3-compatible tools, a key is the name of an object in a bucket.
Copy and securely store your spaces key and its secret to use in your environment so that they’re available to your code.
Configure a Client
To use Spaces with tools or libraries designed for the S3 API, configure the endpoint setting to point to your bucket region.
Use the format $<your-region>.digitaloceanspaces.com, where $<your-region> is the DigitalOcean datacenter region, such as nyc3, where the bucket is located.
Using presigned URLs does not allow transferred files to be cached when using the Spaces CDN. Attempting to do so may result in double the bandwidth charge without the CDN’s performance benefit.
Warning
Because of AWS-specific behavior in all SDKs except Python 3, bucket creation requires an AWS region such as us-east-1 in the client configuration. When a custom region is specified during bucket creation, these SDKs send a different payload, which causes an error.
Setting us-east-1 doesn’t reduce performance, regardless of the bucket location. The SDK uses the region for validation only. It sends the request to the configured custom endpoint instead.
Note
To create a bucket successfully with this SDK, set region to us-east-1, which is an AWS region name. The DigitalOcean datacenter region is determined by the endpoint value.
Set forcePathStyle to false to use subdomain-style, or virtual-hosted-style requests.
Note
To create a bucket successfully with this SDK, set region to us-east-1, which is an AWS region name. The DigitalOcean datacenter region is determined by the endpoint value.
The following example includes additional imports after importing os required by later Go examples below.
Set S3ForcePathStyle to false to use subdomain-style, or virtual-hosted-style requests.
Note
To create a bucket successfully with this SDK, set region to us-east-1, which is an AWS region name. The DigitalOcean datacenter region is determined by the endpoint value.
This example loads the AWS SDK for PHP with Composer’s autoloader.
Note
To create a bucket successfully with this SDK, set region to us-east-1, which is an AWS region name. The DigitalOcean datacenter region is determined by the endpoint value.