Get File Download Link
Updated at:2025-11-03
Get file download URL
Users can obtain the URL of a specified object through the following code:
C
1void test_gen_presinurl(bos_pool_t *p, bos_request_options_t *options, bos_string_t bucket) {
2 bos_string_t object;
3 bos_str_set(&object, "test1");
4 bos_string_t presigned_url;
5 int64_t expire = 300;
6 bos_gen_presigned_url(options, &bucket, &object, expire, HTTP_GET, &presigned_url);
7 printf("presigned_url: %s\n", presigned_url.data);
8 bos_pool_destroy(p);
9}
Description:
- Before calling this function, users need to manually set the endpoint to the domain name of the corresponding region. Baidu AI Cloud currently supports multiple regions. Please refer to[Region Selection Guide](Reference/Region Selection Instructions/Region.md). Currently, the supported regions include "North China-Beijing," "South China-Guangzhou" and "East China-Suzhou." Beijing region:
http://bj.bcebos.com, Guangzhou region:http://gz.bcebos.com, Suzhou region:http://su.bcebos.com.expireis the specified URL validity period, calculated from the current time. It is an optional parameter, and the system default value is 1,800 seconds if not configured. To set a permanent non-expiration time, theexpireparameter can be set to -1. You cannot set it to any other negative value.- If the file to be obtained is expected to be publicly readable, the corresponding URL link can be quickly concatenated and obtained through simple rules:
http://$region.bcebos.com/$bucket/$object
