file

How to configure the preview behavior when accessing OSS files?

When the file in OSS cannot be previewed when accessed in the browser, but is forced to download as an attachment, please check your OSS, CDN, and browser settings.

Screening items

Abnormal causes

resolvent

OSS

Use OSS default domain name or transport to accelerate domain name access. For the sake of data transmission security, when the OSS default domain name or transmission acceleration domain name is used to access specific types of files in the bucket created at a time point (for example, the Content Type is text/html, image/jpeg, etc.), the OSS will force the download header to be added in the return header( x-oss-force-download: true and Content-Disposition: attachment )。 Standard browser detected Content-Disposition: attachment A forced download instead of a preview occurs when. For the description of the x-oss-ec rule that hits when accessing a specific type of file in a bucket created at a specified time and causing a forced download, see Appendix: x-oss-ec Rules for Forced Download Hits

You need to use a custom domain name to access. Before using a custom domain name to access, you need to complete the domain name binding operation. For specific steps, see Bind the custom domain name to the bucket default domain name

Content-Type The value of is inconsistent with the actual file type. The browser cannot parse and render the file correctly, and can only treat it as a download file.

Set a reasonable Content Type according to the file type. See How to set Content Type (MIME)?

Content-Disposition Is set to attachment Browser detected Content-Disposition: attachment The download behavior is triggered when the.

Set Content Disposition to inline For specific steps, see Manage file metadata

CDN

The cache resource was not refreshed.

Refresh CDN cache resources. For specific steps, see Refresh and preheat resources

browser

Preview of files in this format, such as table files, text files, presentation files, and pdf files, is not supported.

You can install plug-ins for your browser to support previewing files in this format. Alternatively, you can use the Smart Media Management IMM to preview documents online. For specific steps, see Document online preview

Appendix: Forced Download Hit X-oss-ec rule

The following is a description of the x-oss-ec rule that hits when you use the OSS default domain name or the transport acceleration domain name to access different types of files.

OSS default domain name

entry-into-force time

Effective object

Content-Type

x-oss-ec

00:00 on or after October 1, 2017

Bucket created

text/html

0048-00000001

17:00 on or after September 23, 2019

  • image/jpeg

  • image/gif

  • image/tiff

  • image/png

  • image/webp

  • image/svg+xml

  • image/bmp

  • image/x-ms-bmp

  • image/x-cmu-raster

  • image/exr

  • image/x-icon

  • image/heic

  • text/html

0048-00000100

11:00 on or after September 24, 2019

0048-00000101

17:00 on or after September 24, 2019

0048-00000102

17:00 on or after September 29, 2019

0048-00000103

18:00 on or after September 29, 2019

0048-00000104

15:00 on or after September 30, 2019

0048-00000105

00:00 on or after October 9, 2022

Users who subscribe to OSS

whole

0048-00000113

Transport acceleration domain name

entry-into-force time

Effective object

Content-Type

x-oss-ec

00:00 on or after December 31, 2020

Hong Kong, China and overseas regions have opened the bucket for transmission acceleration

text/html

0048-00000002

November 17, 2020 11:07 or later

whole

0048-00000106

12:00 on or after January 7, 2021

0048-00000107

18:00 on or after January 7, 2021

0048-00000108

18:00 on or after January 8, 2021

0048-00000109

12:00 on or after January 14, 2021

0048-00000110

00:00 on or after January 16, 2021

0048-00000111

00:00 on or after February 1, 2023

0048-00000112

  • Introduction to this page (1)