Quickstart - SDK
Choose your language and follow along. Each example uploads a file and verifies it. Create the bucket first in the dashboard — CreateBucket over the S3 API is not available in eu-west-1, the default region these examples use.
These examples use eu-west-1, the default region. For a bucket in us-east-1, use https://s3.us-east-1.filonecontent.com and region us-east-1. The endpoint, the region, and your access key must all refer to the same region.
Each example reads your key from the standard AWS environment variables, the same names the console's Download .env writes. Set them in your shell before you run an example, and keep the secret out of your code:
export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
The Python and JavaScript examples upload my-file.txt, so create it first: echo "hello" > my-file.txt.
- Python
- JavaScript
- Go
pip install boto3
import boto3
from botocore.config import Config
s3 = boto3.client(
"s3",
endpoint_url="https://s3.eu-west-1.filonecontent.com",
region_name="eu-west-1",
# Credentials come from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
config=Config(signature_version="s3v4", s3={"addressing_style": "path"}),
)
# Upload a file (create the bucket first in the dashboard)
s3.upload_file("my-file.txt", "my-bucket", "my-file.txt")
# Verify
response = s3.list_objects_v2(Bucket="my-bucket")
for obj in response.get("Contents", []):
print(f"{obj['Key']} ({obj['Size']} bytes)")
npm install @aws-sdk/client-s3
Save this as upload.mjs (it uses ES modules and top-level await), then run node upload.mjs:
import { S3Client, PutObjectCommand, ListObjectsV2Command } from "@aws-sdk/client-s3";
import { readFileSync } from "fs";
const client = new S3Client({
endpoint: "https://s3.eu-west-1.filonecontent.com",
region: "eu-west-1",
forcePathStyle: true,
// SDK v3.729+ adds checksums Fil One doesn't accept on presigned uploads
requestChecksumCalculation: "WHEN_REQUIRED",
responseChecksumValidation: "WHEN_REQUIRED",
// Credentials come from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
});
// Upload a file (create the bucket first in the dashboard)
await client.send(new PutObjectCommand({
Bucket: "my-bucket",
Key: "my-file.txt",
Body: readFileSync("my-file.txt"),
}));
// Verify
const { Contents } = await client.send(
new ListObjectsV2Command({ Bucket: "my-bucket" })
);
Contents?.forEach((obj) => console.log(obj.Key, obj.Size));
mkdir filone-quickstart && cd filone-quickstart
go mod init example.com/filone-quickstart
go get github.com/aws/aws-sdk-go-v2/service/s3
go get github.com/aws/aws-sdk-go-v2/credentials
Save this as main.go and run go run .:
package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
func main() {
client := s3.New(s3.Options{
BaseEndpoint: aws.String("https://s3.eu-west-1.filonecontent.com"),
Region: "eu-west-1",
UsePathStyle: true,
Credentials: credentials.NewStaticCredentialsProvider(
os.Getenv("AWS_ACCESS_KEY_ID"),
os.Getenv("AWS_SECRET_ACCESS_KEY"),
"",
),
})
ctx := context.Background()
// Upload (create the bucket first in the dashboard)
_, err := client.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String("my-bucket"),
Key: aws.String("hello.txt"),
Body: strings.NewReader("Hello from Go!"),
})
if err != nil {
log.Fatal(err)
}
// List
out, err := client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{
Bucket: aws.String("my-bucket"),
})
if err != nil {
log.Fatal(err)
}
for _, obj := range out.Contents {
fmt.Printf("%s (%d bytes)\n", *obj.Key, *obj.Size)
}
}
For more detailed examples including multipart uploads and presigned URLs, see the dedicated SDK pages: