How Do I Configure the Browser to Directly Download or Preview a Video or Picture When Accessing the URL of the Video or Picture?
If you upload a video or image to OBS and allow anonymous users to read the video or image, any anonymous user can use a web browser to access the video or image through its URL. For details about how to obtain the URL of a video or image stored in OBS, see How Do I Obtain the Access Path to an Object?
To view a video or image via a link in the browser, you can:
- Download the media and view it back locally.
- View it online.
Direct Downloading
For example, if a video URL is https://bucketname.obs.cn-north-4.myhuaweicloud.com/video.mp4, add the response-content-disposition=attachment parameter to the end of the video URL, so you can get https://bucketname.obs.cn-north-4.myhuaweicloud.com/video.mp4?response-content-disposition=attachment. You can use this link to download the video.
Online Play or Preview
To play a video or view an image file online, you can:
Method 1: Use a user-defined domain name.
Method 2: Use a temporary URL generated by object sharing.
Regardless of which method is used, you need to configure the object metadata ContentType first. For example, if an MP4 video is uploaded, set Content-Type to video/mp4, or set it to image/jpg for a JPG image. For details about all supported Content-Type values, see About Object Metadata Content-Type.
You can set the object metadata Content-Type on OBS Console, or through the API and SDK.
|
Tool |
Reference |
|---|---|
|
OBS Console |
|
|
API |
|
|
SDK |
Section about setting object attributes in the SDK Reference |
After ContentType is configured, you can play or preview objects online using a user-defined domain name or a temporary URL.
- For details about how to bind a user-defined domain name, see Binding a User-Defined Domain Name. After binding a user-defined domain name, use Bucket's user-defined domain name/Object name for access, for example, www.example.com/image.jpg.
- Generate a temporary URL by sharing an object. For details, see Sharing a File.
If CDN is used, you can also refer to Why Is My .html Static Website File Directly Downloaded When I Access It? if needed.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.