Skip to content
Console

Public read and private

Public read determines whether anonymous requests without a signature can read files. You can set a default for the whole bucket and then set exceptions for certain directories. For example, keep the whole bucket private and make only images/ public, or make the whole bucket public and protect only private/.

To get there, go to Object Storage (对象存储) › Bucket list (桶列表) › click the bucket name › Access management (访问管理) › Public read (公开读取).

Once public, anyone who knows the address can read the files, which generates data transfer and request charges. Use access control to prevent hotlinking.

Which access is affected

Access methodSubject to public read
Anonymous access to the bucket default domain or a bound bucket domainYes
Presigned URLs and requests signed with an AccessKeyNo. Determined by the sub-user's permissions
Access through a CDN domainNo. A CDN that uses an S4 bucket as its origin can read a private bucket

After a private bucket is connected to a CDN, its files can be accessed through the CDN domain. To restrict this, set access control on the CDN.

Public read opens read only: anonymous users can't list files, upload, or delete.

Steps

Set the default

Toggle the switch at the top:

  • Off, private by default: files that match no exception can't be read anonymously.
  • On, public by default: files that match no exception can be read anonymously.

Add directory exceptions (optional)

In the Directory exceptions (目录例外) input, enter a directory such as private/reports, or click Browse (浏览) to choose one. Use the Public / Private (公开 / 不公开) switch on the right to set the result for this directory, then click Add (添加).

The switch for a new directory defaults to the opposite of the bucket default.

Test

Enter an object key in the Test (测试) input, for example private/reports/2026.pdf, and the result and the matching directory appear immediately. Unsaved changes are included in the calculation.

Save

Click Save (保存). If anything changes from private to public, a dialog lists the exact scope, and the change is submitted only after you click Confirm public (确认公开).

Changes take effect immediately after you save. After you switch to private, content already cached in browsers and CDNs isn't invalidated right away.

Matching rules

When an object matches multiple directories, the longest (deepest) directory wins.

Take "private by default, site/ public, site/admin/ private, site/admin/help/ public" as an example:

ObjectMatchesResult
data.csvDefaultPrivate
site/index.htmlsite/Public
site/admin/users.jsonsite/admin/Private
site/admin/help/faq.htmlsite/admin/help/Public
site2/a.pngDefaultPrivate
Site/a.pngDefaultPrivate
  • Directory names are case-sensitive.
  • site/ doesn't match site2/.
  • Consecutive / are merged before matching, so site//a.png is judged as site/a.png.

How to write a directory

RuleDescription
Auto-completiondocs and /docs are both saved as docs/
No wildcardsCan't contain *
Can't be the rootThe root directory is the bucket default
Other limitsNo consecutive /, no . or .. levels, no invisible characters, can't contain !style, up to 512 bytes
QuantityUp to 50 per bucket, and only one entry per directory

When a rule shows "与上级的设置相同,目前没有作用" (same as the parent setting, currently has no effect) below it, you can delete it.

Conditions for widening public access

Changing content from private to public requires all of the following:

ConditionMessage when not met
The account isn't locked because of an overdue balance"您的账号已欠费,充值后才能扩大公开范围" (your account is overdue; top up before you can widen public access)
Identity verification is completeAn Identity verification (实名认证) notice appears
The account has topped up at least once"充值后可使用该功能" (available after you top up)

Narrowing public access (changing to private) is always allowed and isn't subject to these conditions.

You can also turn on Public bucket (公开桶) directly when you create a bucket, which requires an account balance greater than 0. See Bucket management.

Typical configurations

  • Default: private
  • Exception: images/ public

Suits a bucket that holds both business data and public assets.

  • Default: public
  • Exceptions: private/ private, backup/ private

Suits a bucket that mainly holds public assets.

  • Default: private
  • Exceptions: site/ public, site/drafts/ private

A bound bucket domain can point its root path to site/. See Static websites and domains.

FAQ

It's public but still returns 403

Use the returned error code to decide:

  • AccessDenied: Use Test to check whether it matched a private directory, or whether access control blocked it.
  • OriginalFileProtected: Original file protection is enabled.
  • FileTypeForbidden: .apk and .ipa files can't be downloaded from a bucket. Use a CDN.
A public image downloads instead of displaying

The bucket default domain forces downloads. Access it through a CDN domain or a bound bucket domain.

I see "规则已被他人修改,本次没有保存"

Someone else, or another browser window, saved new rules first (the message means "the rules were modified by someone else; this save was not applied"). The page has automatically loaded the latest rules. Make your changes again and save.

I'm told some legacy public grants can't be expressed as directory rules

These early grants still take effect for now, but they are removed after you save new rules. Add the directories that need to be public as directory exceptions first, then save.

I want files to be accessible only for a period of time

Keep them private and control the validity period with presigned URLs.