开发者社区> 问答> 正文

iOS oss上传文件成功,但是在后台不显示,是什么原因,上传代码如下:

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; }];

展开
收起
沙隆巴斯79 2019-09-03 17:45:10 1173 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载