我试图上传一个zip文件并面对这个问题。当我尝试使用旧版本的PutObject方法时,该文件已成功上传,但使用最新的iOS sdk我无法上传文件。
_expression = [AWSS3TransferUtilityUploadExpression new];
_expression.progressBlock = ^(AWSS3TransferUtilityTask task, NSProgress progress) {
dispatch_async(dispatch_get_main_queue(), ^{
// Do something e.g. Update a progress bar.
NSLog(@"Upload Progress '%%'%lld",((task.progress.completedUnitCount*100)/(task.progress.totalUnitCount)));
});
};
_completionHandler = ^(AWSS3TransferUtilityUploadTask task, NSError error) {
dispatch_async(dispatch_get_main_queue(), ^{
// Do something e.g. Alert a user for transfer completion.
// On failed uploads, `error` contains the error object.
if (!error) {
NSLog(@"task completed");
}
else {
NSLog(@"task completed with Error\n\n %@",error);
}
});
};
_transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
[[_transferUtility uploadFile:_uploadFileURL
bucket:_bucketName
key:_key
contentType:@"application/zip"
expression:_expression
completionHander:_completionHandler] continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
}
if (task.exception) {
NSLog(@"Exception: %@", task.exception);
}
if (task.result) {
AWSS3TransferUtilityUploadTask *uploadTask = task.result;
// Do something with uploadTask.
}
return nil;
}];
收到以下错误:
Error Domain=com.amazonaws.AWSS3TransferUtilityErrorDomain Code=2 "(null)" UserInfo={Server=AmazonS3, Transfer-Encoding=Identity, Connection=close, Content-Type=application/xml, Date=Fri, 07 Oct 2016 08:10:37 GMT, x-amz-request-id=F481248FB3DAD978, x-amz-id-2=iWWS/ZrHxtAeIzMD5PmgvE52azggJYumGHNp6aLWB9NgeIfR56yty66n/JfP4SQ/behSLKChEfE=}