nav-img
Advanced

How Do I Preview Objects in OBS in a Browser Online?

Context

OBS prohibits the preview of objects in a bucket by using the default OBS domain name (a bucket domain name or static website domain name). When you use such a domain name to access objects (such as videos, images, and web pages) in a browser, no content will be displayed. Instead, the content is downloaded as an attachment.

Troubleshooting

Use a user-defined domain name to preview objects.

Solution: Use a User-Defined Domain Name

Note

Solution advantages and restrictions

  • The bucket policy must be public read, so that all objects in the bucket can be accessed by anonymous users.
  • Only HTTP requests are supported.

Procedure

  1. Bind a user-defined domain name to the OBS bucket.

    For details, see Configuring a User-Defined Domain Name. During the configuration, add a CNAME record for the OBS bucket domain name.

  2. Check whether objects can be previewed in a browser online.

    Share an object link formatted in http://User-defined domain name/Object access path with other users for them to preview the object.

    If the object still cannot be previewed, check whether the value of the object metadata ContentType is supported by the browser.

    For example, ContentType should be set to video/mp4 for an MP4 video or set to image/jpeg for a JPG image. For details about all supported ContentType values, see About Object Metadata Content-Type.

    You can configure ContentType on OBS Console, or using APIs and SDKs.