Skip to content
Console

S4 quickstart

Follow this page and you'll end up with a working bucket, a file you can access, and a set of AccessKeys you can use in code and third-party tools.

StepWhereWhat you get
1. Sign up and verify your identityConsoleAn account that can create buckets and sub-users
2. Create a bucketObject Storage (对象存储) › Bucket list (桶列表)A globally unique bucket name
3. Upload a fileThe bucket's File management (文件管理)An object
4. Access the fileThe bucket's File managementA signed link or a public link
5. Create a sub-user and keysObject Storage › Sub-users & Keys (子账户&Key)An AccessKey and SecretKey
6. Grant permissions to the sub-userSame as abovePermission to read and write the bucket
7. Connect with an SDKYour codeA working program

Sign up, create a bucket, and upload

Sign up and verify your identity

  1. Open the Bitiful console, then sign up and sign in.
  2. Open Account information, click Identity verification (实名认证) on the Verification status (实名状态) row, and enter your name and ID number.

You can't create buckets or sub-users until you complete identity verification. If your account balance is below 0, you also see the message "您当前已欠费,请先充值" (you are overdue, please top up first).

Create a bucket

  1. Click Object Storage › Bucket list (对象存储 › 桶列表) on the left to open the bucket list.
  2. Click Create bucket (创建桶) in the upper-right corner.
  3. Enter the Bucket name (桶名称): 4 ~ 63 characters, lowercase letters, digits, and hyphens only, beginning and ending with a letter or digit, and unique across the whole platform.
  4. Leave Public bucket (公开桶) off for now. You can make the whole bucket or specific directories public at any time.
  5. Click OK (确定).

For more, see Bucket management.

Upload objects

Upload files
Upload a folder
  1. In the bucket list, click the bucket name to open File management (文件管理).
  2. Click Upload files (上传文件) in the upper-right corner.
  3. Add files in any of these ways:
    • Drag files or folders into the upload area.
    • Click Scan files (扫描文件) and select one or more files.
    • Click Scan folder (扫描文件夹) and select a folder. The files inside keep their original directory structure.
  4. Click Upload files below the table. The Task list (任务列表) on the right shows progress.

For more, see Upload files.

Access the file

In File management, click … on the right of the file:

MenuWhat you getBest for
Copy signed URL (复制签名URL)A signed link, valid for 1 hourPrivate buckets, temporary sharing
Copy public URL (复制公开URL)https://bucket-name.s3.bitiful.net/file-path, with no signatureFiles that are already public

If the file isn't public, opening the public URL returns 403 AccessDenied.

Opening a file in a browser through the bucket default domain (bucket-name.s3.bitiful.net) triggers a download instead of a preview. To display images, videos, or pages directly in a web page, access them through a CDN domain.

The bucket default domain also can't download .apk or .ipa files. These files must be distributed through a CDN.

Create a sub-user and keys

An AccessKey belongs to a sub-user. Your code and third-party tools such as Rclone and image hosting apps connect to S4 with a sub-user's AccessKey, not your login password.

Add a sub-user

  1. Go to Object Storage › Sub-users & Keys (子账户&Key).
  2. Click Add sub-user (添加子用户), enter a Sub-user name (子用户名) (3 ~ 12 English letters or digits, which can't be changed after you add it), and click OK.
  3. A dialog shows an Access Key and a Secret Key. Copy and save them right away.

Save the keys

The Secret Key is shown only this once. If you didn't save it, your only option is to Add key (添加 Key) again. See Sub-users and AccessKeys.

Grant permissions to the sub-user

A newly created sub-user has no permissions. This is the most common cause of 403 errors when you first connect.

Open permission settings

In the dialog shown after you add the sub-user, click Set permissions (设定权限). You can also click Set permissions for that sub-user later in the Sub-user management (子用户管理) table.

Select permissions

Find your bucket and select Read (读), Write (including delete) (写(含删除)), and List (列表). To open up only a certain directory, click + Add directory (+ 添加目录).

Save

Click Save changes (保存更改) at the bottom. The change takes effect in about 1 second.

For the operations each permission covers, see Sub-user permissions.

Connect with an SDK

S4 is S3 compatible. With any S3 SDK, you only need to change four settings:

SettingValue
Endpointhttps://s3.bitiful.net
Regioncn-east-1
Access Key IDThe sub-user's Access Key
Secret Access KeyThe sub-user's Secret Key

The examples below upload a text file and then generate a download link that is valid for 10 minutes. Before you run them, set the environment variables S4_ACCESS_KEY and S4_SECRET_KEY, and replace my-bucket with your bucket name.

// npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";

const s3 = new S3Client({
  endpoint: "https://s3.bitiful.net",
  region: "cn-east-1",
  credentials: {
    accessKeyId: process.env.S4_ACCESS_KEY,
    secretAccessKey: process.env.S4_SECRET_KEY,
  },
});

const Bucket = "my-bucket";
const Key = "hello.txt";

await s3.send(new PutObjectCommand({ Bucket, Key, Body: "Hello S4", ContentType: "text/plain" }));
const url = await getSignedUrl(s3, new GetObjectCommand({ Bucket, Key }), { expiresIn: 600 });
console.log(url);

For other languages, see the SDK overview.

Never put your SecretKey in a web page, an app, or a public code repository. For uploads from browsers and apps, have your server issue presigned URLs.

FAQ

The SDK returns 403 AccessDenied

Check the following in order:

  1. Whether the sub-user has been granted access to this bucket with the right permissions selected.
  2. Whether the object is inside an authorized directory.
  3. Whether the bucket name and endpoint are correct.

Sub-users can't create or delete buckets. Create buckets in the console.

Creating a bucket prompts for identity verification

Click Verify now (去认证) in the prompt, or open Account information directly to complete identity verification.

The file downloads instead of opening

This is fixed behavior of the bucket default domain. Access the file through a CDN domain to display it directly in the browser.

Next steps