Skip to content
Console

Original file protection

After you turn on original file protection, visitors can't anonymously get original files of the specified types directly, and can't compose their own processing parameters. They can access only the versions you defined in Styles. It suits photography, e-commerce, asset libraries, and other scenarios where you need to protect high-resolution originals, and it also stops visitors from generating arbitrary sizes.

To get there, go to Object Storage (对象存储) › Bucket list (桶列表) › click the bucket name › Media processing (媒体处理) › Original file protection (原文件保护).

Steps to turn it on

Create a style first

Create at least one style, for example preview: w=1600&fmt=auto.

Edit

On the Original file protection card, click Edit (编辑) and set Protection status (保护状态) to On (do not allow access to original files) (开启(不允许访问原文件)).

Choose types and a default style

Set Protected media types (保护媒体类型) and Default Style (默认Style), as described below.

Save

Click Save (保存), and it takes effect immediately. Original files already cached by a CDN or browser become protected only after you purge the cache.

Protection statussingle choiceDefault Off (original files accessible)

Whether protection is on. When off, all types return to normal access.

Protected media typesmultiple choice, custom input allowed

Judged by the file's Content-Type. image/* and video/* are common. You can also choose specific types such as image/jpeg, or enter a type that isn't in the list. Choose at least one; otherwise it's the same as not turning it on. All types joined together can't exceed 500 characters.

After you choose image/*, individual image/... entries are merged. Choosing * means all files in the bucket.

Default Stylesingle choiceDefault None (block access)

How to handle access to a protected original file. None (block access) (无 (阻止访问)): Returns 403 OriginalFileProtected. Choose a style: The result processed by that style is returned automatically.

Access behavior

Take protecting image/* with a style preview in the bucket as an example:

Access methodDefault Style is "None"Default Style is preview
a.jpg403Returns the preview result
a.jpg?w=3000403Returns the preview result; w is ignored
a.jpg!style:previewNormalNormal
Presigned URLs and AccessKey-signed requestsReturns the originalReturns the original
data.jsonNormalNormal
  • Both anonymous access and access through CDN domains are protected.
  • When the default style is triggered, the response carries the header x-bitiful-defaultstyle: Enable to help with troubleshooting.
  • Variable parameters declared with * in the default style can still be overridden by visitors.

Recommendations

  • For an image site, choose image/* plus a default style. Old links need no changes and automatically become the downsized or watermarked version.
  • For buckets that include web pages, scripts, archives, and similar files, don't choose *. * plus a default style sends those files into image processing and returns 415.
  • After you set a default style, a link's extension may differ from the actual format (for example, .jpg returns WebP). This is normal.
  • Files with no Content-Type or an incorrect type don't match, so make sure the type is correct when you upload.
  • To hand an original to a specific user, use a presigned URL.

How it interacts with other features

FeatureRelationship
Public readWhether the file can be read is decided first, then whether it's protected. Original file protection doesn't make private files accessible
Access controlBoth apply at the same time
StyleA style set as the Default Style can't be deleted
Mirror back-to-originProtection is judged by the type of the file in the bucket. Migrate files that need protection into the bucket in advance and don't rely on the first origin fetch

FAQ

It returns 403 OriginalFileProtected

You accessed a protected original file. Use !style:style-name instead, or set a Default Style.

The original image is still visible on the CDN after I turned it on

The CDN has it cached. Purge the corresponding address or directory on the CDN.

I see "请选择存在的style作为默认style"

The message means "please choose an existing style as the default style". The style was just deleted. Refresh the page and choose again.

I see "超过最大长度限制"

The message means "exceeds the maximum length". You chose too many types. Use image/* and video/* instead of choosing them one by one.