tencent cloud

All product documents
Cloud Object Storage
Object Access URL
Last updated: 2024-02-02 14:36:36
Object Access URL
Last updated: 2024-02-02 14:36:36

Overview

This document provides a code sample for generating an object access URL.
Note:
The object access URL generation method described in this document applies only to the scenario where the default domain is used to access public-read objects.
For how to access private-read objects, see Getting Pre-Signed URLs.

Generating Object Access URLs

If the ACL attribute of an object is set to public-read, you can directly access the object using the URL generated by the following SDK API (only the URL for COS's default origin server domain can be generated):
try
{
// Bucket name in the format of `BucketName-APPID`. You can get APPID by referring to https://console.tencentcloud.com/developer.
string bucket = "examplebucket-1250000000";
string key = "exampleobject"; // Object key
// Generate a public-read object URL
string requestURL = cosXml.GetObjectUrl(bucket, key);
// Request succeeded
Console.WriteLine(requestURL);
}
catch (COSXML.CosException.CosClientException clientEx)
{
// Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
// Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note:
For the complete sample, go to GitHub.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon