Documentation menu: Object Storage
S3 · Beta Updated

SDKs and temporary links

boto3 and AWS SDK for JavaScript examples for uploads, listings and presigned URLs

S3 SDKs work once the endpoint and region point at XVer. These examples use path-style addressing and read the key from environment variables; never put the secret access key in your code. Both keys come from an API token with Object Storage permission (steps).

Terminal
export XVER_S3_KEY=<ACCESS_KEY_ID>
export XVER_S3_SECRET=<SECRET_ACCESS_KEY>

Python (boto3)#

python
import os
import boto3
from botocore.config import Config

s3 = boto3.client(
    "s3",
    endpoint_url="https://bkk1.xverstorage.com",
    region_name="bkk1",
    aws_access_key_id=os.environ["XVER_S3_KEY"],
    aws_secret_access_key=os.environ["XVER_S3_SECRET"],
    config=Config(signature_version="s3v4", s3={"addressing_style": "path"}),
)

s3.upload_file("invoice.pdf", "my-docs", "2026/invoice.pdf")

for obj in s3.list_objects_v2(Bucket="my-docs", Prefix="2026/").get("Contents", []):
    print(obj["Key"], obj["Size"])

# Download link valid for 1 hour
url = s3.generate_presigned_url(
    "get_object", Params={"Bucket": "my-docs", "Key": "2026/invoice.pdf"}, ExpiresIn=3600
)
print(url)

upload_file splits large files into parts (multipart) for you.

Node.js (AWS SDK for JavaScript v3)#

Terminal
npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
js
import { S3Client, PutObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { readFile } from 'node:fs/promises';

const s3 = new S3Client({
    endpoint: 'https://bkk1.xverstorage.com',
    region: 'bkk1',
    forcePathStyle: true,
    credentials: { accessKeyId: process.env.XVER_S3_KEY, secretAccessKey: process.env.XVER_S3_SECRET },
});

await s3.send(new PutObjectCommand({
    Bucket: 'my-docs', Key: '2026/invoice.pdf', Body: await readFile('invoice.pdf'), ContentType: 'application/pdf',
}));

const { Contents = [] } = await s3.send(new ListObjectsV2Command({ Bucket: 'my-docs', Prefix: '2026/' }));
console.log(Contents.map((o) => o.Key));

// Download link valid for 1 hour
const url = await getSignedUrl(s3, new GetObjectCommand({ Bucket: 'my-docs', Key: '2026/invoice.pdf' }), { expiresIn: 3600 });
console.log(url);

For large files use Upload from @aws-sdk/lib-storage, which sends them in parts.

A temporary link lets someone without a key open or upload one file until it expires. The bucket stays private.

aws-cli

Terminal
aws s3 presign s3://my-docs/2026/invoice.pdf --expires-in 3600 --profile xver

Upload link (boto3)

python
upload_url = s3.generate_presigned_url(
    "put_object",
    Params={"Bucket": "my-docs", "Key": "uploads/report.pdf", "ContentType": "application/pdf"},
    ExpiresIn=900,
)

The recipient uploads with PUT, sending the same Content-Type that was signed:

Terminal
curl -X PUT -H "Content-Type: application/pdf" --upload-file report.pdf "$UPLOAD_URL"