AWS SDK IOS - uploadRequest仍为零

时间:2016-09-21 13:24:26

标签: ios amazon-s3

NSString* path = [[NSBundle mainBundle] pathForResource:@"myTestFile"
                                                 ofType:@"txt"];

AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = S3BucketName;
uploadRequest.key = @"myTestFile.txt";
uploadRequest.body = [NSURL fileURLWithPath:path];


AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

[[transferManager upload:uploadRequest] continueWithExecutor:[AWSExecutor mainThreadExecutor]
                                                   withBlock:^id(AWSTask *task) {
                                                       if (task.error) {
                                                           if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
                                                               switch (task.error.code) {
                                                                   case AWSS3TransferManagerErrorCancelled:
                                                                   case AWSS3TransferManagerErrorPaused:
                                                                       break;

                                                                   default:
                                                                       NSLog(@"Error: %@", task.error);
                                                                       break;
                                                               }
                                                           } else {
                                                               // Unknown error.
                                                               NSLog(@"Error: %@", task.error);
                                                           }
                                                       }

                                                       if (task.result) {
                                                           AWSS3TransferManagerUploadOutput *uploadOutput = task.result;
                                                           NSLog(@"The file uploaded successfully");
                                                           // The file uploaded successfully.
                                                       }
                                                       return nil;
                                                   }];

无法通过执行此操作来上传文件。 。 。应用程序启动后所有对象都保持为零。 。 。 uploadRequest 以及 transferManager 。 。

0 个答案:

没有答案