AWSBasicSessionCredentialsProvider * provider = [[AWSBasicSessionCredentialsProvider alloc] initWithAccessKey:weakSelf.awsCredential.key secretKey:weakSelf.awsCredential.secret sessionToken:weakSelf.awsCredential.token];
AWSEndpoint *endpoint = [[AWSEndpoint alloc] initWithURLString:@"https://s3.amazonaws.com"];
AWSServiceConfiguration *config = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 endpoint:endpoint credentialsProvider:provider];
config.timeoutIntervalForRequest = 30;
config.timeoutIntervalForResource = 30;
config.maxRetryCount = 1;
AWSServiceManager *serviceManager = [AWSServiceManager defaultServiceManager];
serviceManager.defaultServiceConfiguration = config;
AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
AWSS3TransferUtilityUploadExpression *expression = [AWSS3TransferUtilityUploadExpression new];
expression.progressBlock = uploadProgress;
NSString *bucket = [AWSS3Configure sharedManager].bucketName;
NSString *key = objectKey;
NSString *contentType = @"image/jpeg";
AWSTask<AWSS3TransferUtilityUploadTask *> *task = [transferUtility uploadData:dataToUpload bucket:bucket key:key contentType:contentType expression:expression completionHandler:^(AWSS3TransferUtilityUploadTask * _Nonnull task, NSError * _Nullable error) {
NSString *fileUrl = [[AWSS3Configure sharedManager].hostUrl stringByAppendingFormat:@"/%@",objectKey];
if (!error) {
[subscriber sendNext:fileUrl];
[subscriber sendCompleted];
YSLog(@"Upload to %@ success", fileUrl);
} else {
[subscriber sendError:error];
YSLog(@"Upload to %@ failed", fileUrl);
}
}];
错误Domain = com.amazonaws.AWSS3TransferUtilityErrorDomain Code = 2“(null)”UserInfo = {Server = AmazonS3,Transfer-Encoding = Identity,Connection = close,Content-Type = application / xml,Date = Mon,Jun Jun 2017 06:37:51 GMT,x-amz-request-id = A5E32BD17E6558F5,
这是错误的。怎么做?