Help & Documentation>Cloud Object Storage>SDK Documentation>iOS SDK>Setting Access Domain Names (CDN/Global Acceleration)

Setting Access Domain Names (CDN/Global Acceleration)

Last updated: 2023-09-13 15:10:09

Feature Overview

This document describes how to request the COS service by using a non-default domain name.

SDK API References

For detailed parameters and method descriptions of all SDK interfaces, please refer to SDK API.

Default CDN acceleration domain name

The sample code below shows how to access a COS service using a default CDN acceleration domain name.

Sample code

Objective-C
QCloudCOSXMLEndPoint *endpoint = [[QCloudCOSXMLEndPoint alloc]init];
endpoint.suffix = @"file.myqcloud.com";
Note
For the complete sample, go to GitHub.
Swift
let endpoint = QCloudCOSXMLEndPoint();
endpoint.suffix = "file.myqcloud.com";
Note
For the complete sample, go to GitHub.

Custom CDN acceleration domain name

The sample code below shows how to access a COS service using a custom CDN acceleration domain name.

Sample code

Objective-C
QCloudCOSXMLEndPoint *endpoint = [[QCloudCOSXMLEndPoint alloc] initWithLiteralURL:[NSURL URLWithString:@"exampledomain.com"]];
Note
For the complete sample, go to GitHub.
Swift
let endpoint = QCloudCOSXMLEndPoint.init(literalURL: NSURL.init(string: "exampledomain.com") as URL?);
Note
For the complete sample, go to GitHub.

Custom origin domain name

For more information, see Enabling Custom Origin Domain.
The sample code below shows how to access a COS service using a custom origin server domain name.

Sample code

Objective-C
NSString *customDomain = @"exampledomain.com"; // Custom acceleration domain name
QCloudCOSXMLEndPoint *endpoint = [[QCloudCOSXMLEndPoint alloc] initWithLiteralURL:[NSURL URLWithString:customDomain]];
Note
For the complete sample, go to GitHub.
Swift
let endpoint = QCloudCOSXMLEndPoint.init(literalURL: NSURL.init(string: "exampledomain.com") as URL?);
Note
For the complete sample, go to GitHub.

Global acceleration domain name

For information about the Global Acceleration feature, see Global Acceleration Feature Overview.
The sample code below shows how to access a COS service using a global acceleration endpoint.

Sample code

Objective-C
QCloudCOSXMLEndPoint *endpoint = [[QCloudCOSXMLEndPoint alloc]init];
endpoint.suffix = @"cos.accelerate.myqcloud.com";
Note
For the complete sample, go to GitHub.
Swift
let endpoint = QCloudCOSXMLEndPoint();
endpoint.suffix = "cos.accelerate.myqcloud.com";
Note
For the complete sample, go to GitHub.