Get file download URL
Updated at:2025-11-03
Users can obtain the URL of a specified object through the following code:
Ruby
1options = { 'expiration_in_seconds' => 360,
2 'timestamp' => Time.now.to_i
3}
4puts client.generate_pre_signed_url(bucket_name, object_name, options)
5# If the temporary AK, SK and Token obtained through STS method is used to generate access URLs, the specified header must be carried in the HTTP request by oneself: <x-bce-security-token: sessionToken value>
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.EXPIRATION_IN_SECONDSis 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, theexpiration_in_secondsparameter can be set to -1. You cannot set it to any other negative value.TIMESTAMPis an optional parameter. If not configured, the system defaults TIMESTAMP to the current time.- 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://bucketName.$region.bcebos.com/$bucket/$object
