Skip to content

SDKs with WebShield S3

Any AWS SDK works with WebShield object storage — point the S3 client at the WebShield endpoint and enable path-style addressing. See Object storage for how to obtain your keys and create buckets.

  • Endpoint: https://s3.webshield.pro
  • Access Key ID and Secret Access Key from the S3 storage page in the control panel.
  • The full bucket name including the account prefix (for example, u42-backups).

Do not hard-code the secret key in source code — read it from an environment variable or a secrets manager.

import boto3
s3 = boto3.client(
"s3",
endpoint_url="https://s3.webshield.pro",
aws_access_key_id="WSS...",
aws_secret_access_key="<secret>",
region_name="us-east-1", # any value; not used by WebShield
)
s3.upload_file("backup.tar.gz", "u42-backups", "db/backup.tar.gz")
s3.download_file("u42-backups", "db/backup.tar.gz", "restored.tar.gz")
for obj in s3.list_objects_v2(Bucket="u42-backups", Prefix="db/").get("Contents", []):
print(obj["Key"], obj["Size"])

boto3 uses path-style addressing by default when a custom endpoint_url is set.

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { readFileSync } from "node:fs";
const s3 = new S3Client({
endpoint: "https://s3.webshield.pro",
region: "us-east-1",
forcePathStyle: true,
credentials: {
accessKeyId: "WSS...",
secretAccessKey: process.env.WS_SECRET_KEY,
},
});
await s3.send(new PutObjectCommand({
Bucket: "u42-backups",
Key: "db/backup.tar.gz",
Body: readFileSync("backup.tar.gz"),
}));

forcePathStyle: true is required.

cfg, _ := config.LoadDefaultConfig(context.TODO(),
config.WithRegion("us-east-1"),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
"WSS...", os.Getenv("WS_SECRET_KEY"), "")),
)
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String("https://s3.webshield.pro")
o.UsePathStyle = true
})
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'endpoint' => 'https://s3.webshield.pro',
'use_path_style_endpoint' => true,
'credentials' => [
'key' => 'WSS...',
'secret' => getenv('WS_SECRET_KEY'),
],
]);
  • The region is required by the SDKs but ignored by WebShield — any value works.
  • Enable path-style addressing (forcePathStyle / UsePathStyle / use_path_style_endpoint); boto3 does this automatically for custom endpoints.
  • Buckets are created and deleted only in the control panel; SDK CreateBucket/DeleteBucket calls are not available.
  • If the account balance goes negative, storage becomes read-only: uploads fail while downloads keep working. Top up the balance to restore writes.