Overview
This document provides code samples to obtain an object URL.
Note:
This API is used to query the URL to access an object. It does not verify whether the object exists or not.
The URL generated using this API cannot be used to access private-read objects. For such objects, you can generate a URL by referring to Generating Pre-Signed URLs. SDK API References
For parameters and method description of all APIs in the SDK, please see SDK API Reference. Obtaining Object URLs
Sample code 1. Obtaining an object access URL
Objective-C
QCloudGetPresignedURLRequest* getPresignedURLRequest = [[QCloudGetPresignedURLRequest alloc] init];
getPresignedURLRequest.isUseSignature = false:
getPresignedURLRequest.bucket = @"examplebucket-1250000000";
getPresignedURLRequest.object = @"exampleobject";
[getPresignedURLRequest setFinishBlock:^(QCloudGetPresignedURLResult * _Nonnull result,
NSError * _Nonnull error) {
NSString* presignedURL = result.presienedURL;
}];
[[QCloudCOSXMLService defaultCOSXML] getPresignedURL:getPresignedURLRequest];
Note:
For the complete sample, go to GitHub. Swift
let getPresign = QCloudGetPresignedURLRequest.init();
getPresign.isUseSignature = false;
getPresign.bucket = "examplebucket-1250000000" ;
getPresign.object = "exampleobject";
getPresign.setFinish { (result, error) in
if let result = result {
let url = result.presienedURL
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().getPresignedURL(getPresign);
Note:
For the complete sample, go to GitHub.
Was this page helpful?