Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Accepted Answer
PHP - (AWS docs)
<?php
// Included aws/aws-sdk-php via Composer's autoloader
// Installed with: composer.phar require aws/aws-sdk-php
require 'vendor/autoload.php';
use Aws\S3\S3Client;
// Configure a client using Spaces
$client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'nyc3',
'endpoint' => 'https://nyc3.digitaloceanspaces.com',
'credentials' => [
'key' => 'ACCESS_KEY',
'secret' => 'SECRET_KEY',
],
]);
// Create a new Space
$client->createBucket([
'Bucket' => 'my-new-space-with-a-unique-name',
]);
// Listing all Spaces in the region
$spaces = $client->listBuckets();
foreach ($spaces['Buckets'] as $space){
echo $space['Name']."\n";
}
// Upload a file to the Space
$insert = $client->putObject([
'Bucket' => 'my-new-space-with-a-unique-name',
'Key' => 'file.ext',
'Body' => 'The contents of the file'
]);
Working C# example using Amazon AWSSDK (V2.x).
IAmazonS3 amazonS3Client =
AWSClientFactory.CreateAmazonS3Client("your-spaces-key", "your-spaces-key-secrete",
new AmazonS3Config
{
ServiceURL = "https://nyc3.digitaloceanspaces.com"
}
);
var myBuckets = amazonS3Client.ListBuckets();
Go - (AWS Docs)
package main
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
// Initialize a client using Spaces
s3Config := &aws.Config{
Credentials: credentials.NewStaticCredentials("ACCESS_KEY", "SECRET_KEY", ""),
Endpoint: aws.String("https://nyc3.digitaloceanspaces.com"),
Region: aws.String("us-east-1"), // This is counter intuitive, but it will fail with a non-AWS region name.
}
newSession := session.New(s3Config)
s3Client := s3.New(newSession)
// Create a new Space
params := &s3.CreateBucketInput{
Bucket: aws.String("my-new-space-with-a-unique-name"),
}
_, err := s3Client.CreateBucket(params)
if err != nil {
fmt.Println(err.Error())
return
}
// List all Spaces in the region
spaces, err := s3Client.ListBuckets(nil)
if err != nil {
fmt.Println(err.Error())
return
}
for _, b := range spaces.Buckets {
fmt.Printf("%s\n", aws.StringValue(b.Name))
}
// Upload a file to the Space
object := s3.PutObjectInput{
Body: strings.NewReader("The contents of the file"),
Bucket: aws.String("my-new-space-with-a-unique-name"),
Key: aws.String("file.ext"),
}
_, err = s3Client.PutObject(&object)
if err != nil {
fmt.Println(err.Error())
return
}
}