API | 操作名 | 操作描述 |
预请求跨域配置 | 用预请求来确认是否可以发送真正的跨域请求 |
QCloudOptionsObjectRequest* request = [[QCloudOptionsObjectRequest alloc] init];// 存储桶名称,格式:BucketName-APPIDrequest.bucket =@"examplebucket-1250000000";// 模拟跨域访问的请求来源域名,请求 method,请求 hostrequest.origin = @"http://cloud.tencent.com";request.accessControlRequestMethod = @"GET";request.accessControlRequestHeaders = @"host";// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"request.object = @"exampleobject";[request setFinishBlock:^(id outputObject, NSError* error) {// 可以从 outputObject 中获取 response 中 etag 或者自定义头部等信息NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] OptionsObject:request];
let optionsObject = QCloudOptionsObjectRequest.init();// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"optionsObject.object = "exampleobject";// 模拟跨域访问的请求来源域名,请求 method,请求头部optionsObject.origin = "http://www.qcloud.com";optionsObject.accessControlRequestMethod = "GET";optionsObject.accessControlRequestHeaders = "origin";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketoptionsObject.bucket = "examplebucket-1250000000";optionsObject.finishBlock = {(result,error) inif let result = result {// 可以从 result 中获取服务器返回的 header 信息}}QCloudCOSXMLService.defaultCOSXML().optionsObject(optionsObject);
本页内容是否解决了您的问题?