NSString *endpoint = @"http://oss-cn-hangzhou.aliyuncs.com";
id credential = [[OSSPlainTextAKSKPairCredentialProvider alloc] initWithPlainTextAccessKey:kAccessKey secretKey:kSecretKey];
OSSClientConfiguration * conf = [OSSClientConfiguration new]; conf.maxRetryCount = 3; // 网络请求遇到异常失败后的重试次数 conf.timeoutIntervalForRequest = 30; // 网络请求的超时时间 conf.timeoutIntervalForResource = 24 * 60 * 60; // 允许资源传输的最长时间 OSSClient *client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential clientConfiguration:conf]; OSSPutObjectRequest *put = [OSSPutObjectRequest new]; put.bucketName = kBucketName; put.objectKey = [NSString stringWithFormat:@"USERS/USER1/%@/setting.txt", self.frameID]; put.uploadingFileURL = [NSURL fileURLWithPath:filePath];; // optional fields put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) { NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend); }; OSSTask *putTask = [client putObject:put]; [putTask continueWithBlock:^id _Nullable(OSSTask * _Nonnull task) { if (!task.error) { GFFLog(@"上传成功"); }else{ GFFLog(@"上传失败:%@", task.error); } return nil; }];
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。