ZoCloud User Guide Tiếng Việt Open ZoCloud

Object storage (S3)

S3 buckets located in Vietnam for your app's files: uploads, images, backups. They work with any S3 client or SDK (AWS SDK, boto3, rclone, s3cmd…).

Setting Value
Endpoint https://s3.zocloud.app
Region shown on the bucket page (the S3_REGION variable)
Addressing path-style (https://s3.zocloud.app/<bucket>/<key>)
Largest single upload 100 MB; larger files use multipart upload (the SDK does this for you)

Creating a bucket

  1. On the project canvas, click Add → Object storage (S3).
  2. Enter a Name (lower-case letters, digits, -), for example files. Services refer to the bucket by this name in their variables.
  3. Enter the Size limit (GB). Writes beyond the limit are refused; you pay for the space actually used.
  4. Click Create.

Connecting from a service

The Connect section shows the reference variables; add them to the service's Variables and redeploy:

S3_ENDPOINT=${{files.S3_ENDPOINT}}
S3_BUCKET=${{files.S3_BUCKET}}
S3_ACCESS_KEY_ID=${{files.S3_ACCESS_KEY_ID}}
S3_SECRET_ACCESS_KEY=${{files.S3_SECRET_ACCESS_KEY}}

The bucket's available variables:

Variable Note
S3_ENDPOINT, S3_REGION, S3_BUCKET
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
S3_FORCE_PATH_STYLE always true
AWS_ENDPOINT_URL_S3, AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY AWS-style names, so SDKs pick them up on their own

Each bucket has its own access key, which can only reach this bucket. See the full values under Connection variables → Show connection details (for rclone, scripts on your computer…).

Example (Node.js, AWS SDK v3)

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

const s3 = new S3Client({
  endpoint: process.env.S3_ENDPOINT,
  region: process.env.S3_REGION,
  forcePathStyle: true,
  credentials: {
    accessKeyId: process.env.S3_ACCESS_KEY_ID,
    secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
  },
});

await s3.send(new PutObjectCommand({ Bucket: process.env.S3_BUCKET, Key: "hello.txt", Body: "Xin chào" }));

Example (Python, boto3)

import os, boto3

s3 = boto3.client(
    "s3",
    endpoint_url=os.environ["S3_ENDPOINT"],
    region_name=os.environ["S3_REGION"],
    aws_access_key_id=os.environ["S3_ACCESS_KEY_ID"],
    aws_secret_access_key=os.environ["S3_SECRET_ACCESS_KEY"],
    config=boto3.session.Config(s3={"addressing_style": "path"}),
)
s3.put_object(Bucket=os.environ["S3_BUCKET"], Key="hello.txt", Body=b"Xin chao")

Usage

The Usage section shows the space used, the limit and the number of files (measured periodically, not in real time). Click Change the limit to set a new limit. Total object storage is a limit of your plan.

Deleting a bucket

Danger zone → Delete the bucket, type the name to confirm. Every file in the bucket is deleted, then the bucket and its key. This cannot be undone.