NSString *endpoint = @"";
// 明文设置secret的方式建议只在测试时使用,更多鉴权模式请参考后面的`访问控制`章节
// NSLog(@"--%@--%@--%@",self.accessKeyId,self.accessKeySecret,self.securityToken);
id<OSSCredentialProvider> credential = [[OSSStsTokenCredentialProvider alloc] initWithAccessKeyId:self.accessKeyId secretKeyId:self.accessKeySecret securityToken:self.securityToken];
//设置网络请求的一些参数
OSSClientConfiguration * conf=[OSSClientConfiguration new];
//最大重试次数
conf.maxRetryCount=3;
conf.timeoutIntervalForRequest=30;// 网络请求的超时时间
OSSClient* client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential];
OSSHeadObjectRequest * head = [OSSHeadObjectRequest new];
head.bucketName = @"
head.objectKey = @"
OSSTask * headTask = [client headObject:head];
[headTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
OSSHeadObjectResult * headResult = task.result;
NSLog(@"all response header: %@", headResult.httpResponseHeaderFields);
// some object properties include the 'x-oss-meta-*'s
NSLog(@"head object result: %@", headResult.objectMeta);
} else {
NSLog(@"head object error: %@", task.error);
}
return nil;
}];