This topic describes the causes of and solutions to the issue that an object cannot be previewed but is downloaded when a browser is used to access the object.

Issue description

An object cannot be previewed but is downloaded when a browser is used to access the object.

Causes

  • When you use an Object Storage Service (OSS) default domain name or acceleration endpoint to access an object of a specific type in a bucket created at a specific point in time, OSS adds the following headers to the response:
    x-oss-force-download: true
    Content-Disposition: attachment

    When a browser detects that the Content-Disposition header is set to attachment, the object is downloaded.

  • The Content-Type header is set to application/octet-stream. The application/octet-stream is a binary download stream. As a result, the object is downloaded.
  • The Content-Disposition header is set to attachment.
  • The Content Delivery Network (CDN) caches the invalid value of the Content-Type header or the Content-Disposition header.
  • The browser does not support previews of the object or image in this format.

Solutions

  • If an object is downloaded because you use the default domain name or acceleration endpoint to access the object, you must use a custom domain name to access the object. For more information, see Use custom domain names to access OSS resources.
  • If an object is downloaded because the Content-Type header is set to application/octet-stream, you must specify a valid value for the Content-Type header and make sure that the browser supports previews of the object in this format. For more information about the Content-Type header, see How do I specify the Content-Type header?.
  • If an object is downloaded because the Content-Disposition header is set to attachment, you must set the Content-Disposition header to inline. For more information, see Manage object metadata.
  • If an object is downloaded because CDN caches the invalid value of the Content-Type header or the Content-Disposition header, you must update the CDN cache.
  • If an object is downloaded because the browser does not support previews of the object in this format, you must install a plug-in that allows you to preview the object in the current format in a browser.