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
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.
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.
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 method | Default Style is "None" | Default Style is preview |
|---|---|---|
a.jpg | 403 | Returns the preview result |
a.jpg?w=3000 | 403 | Returns the preview result; w is ignored |
a.jpg!style:preview | Normal | Normal |
| Presigned URLs and AccessKey-signed requests | Returns the original | Returns the original |
data.json | Normal | Normal |
- Both anonymous access and access through CDN domains are protected.
- When the default style is triggered, the response carries the header
x-bitiful-defaultstyle: Enableto 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,
.jpgreturns 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
| Feature | Relationship |
|---|---|
| Public read | Whether the file can be read is decided first, then whether it's protected. Original file protection doesn't make private files accessible |
| Access control | Both apply at the same time |
| Style | A style set as the Default Style can't be deleted |
| Mirror back-to-origin | Protection 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.