SDKs with WebShield S3
Use AWS SDKs (boto3, JavaScript, Go, PHP) with WebShield S3-compatible object storage.
Any AWS SDK works with WebShield object storage — point the S3 client at the WebShield endpoint. Both path-style and virtual-hosted addressing are supported. See Object storage for how to obtain your keys and create buckets.
Prerequisites
Section titled “Prerequisites”- Endpoint:
https://s3.webshield.pro - Access Key ID and Secret Access Key from the S3 storage page in the control panel.
- The exact bucket name from the control panel (for example,
company-backups).
Do not hard-code the secret key in source code — read it from an environment variable or a secrets manager.
Python (boto3)
Section titled “Python (boto3)”import boto3from botocore.config import Config
s3 = boto3.client( "s3", endpoint_url="https://s3.webshield.pro", config=Config(signature_version="s3v4", request_checksum_calculation="when_required"), aws_access_key_id="WSS...", aws_secret_access_key="<secret>",)
s3.upload_file("backup.tar.gz", "company-backups", "db/backup.tar.gz")s3.download_file("company-backups", "db/backup.tar.gz", "restored.tar.gz")
for obj in s3.list_objects_v2(Bucket="company-backups", Prefix="db/").get("Contents", []): print(obj["Key"], obj["Size"])JavaScript (AWS SDK v3)
Section titled “JavaScript (AWS SDK v3)”import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";import { readFileSync } from "node:fs";
const s3 = new S3Client({ endpoint: "https://s3.webshield.pro", region: "ru-1", credentials: { accessKeyId: "WSS...", secretAccessKey: process.env.WS_SECRET_KEY, },});
await s3.send(new PutObjectCommand({ Bucket: "company-backups", Key: "db/backup.tar.gz", Body: readFileSync("backup.tar.gz"),}));Go (aws-sdk-go-v2)
Section titled “Go (aws-sdk-go-v2)”cfg, _ := config.LoadDefaultConfig(context.TODO(), config.WithRegion("ru-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")})PHP (aws-sdk-php)
Section titled “PHP (aws-sdk-php)”$s3 = new Aws\S3\S3Client([ 'version' => 'latest', 'region' => 'ru-1', 'endpoint' => 'https://s3.webshield.pro', 'credentials' => [ 'key' => 'WSS...', 'secret' => getenv('WS_SECRET_KEY'), ],]);