iOS AWS Transfer Utility上传请求不添加标题或参数

时间:2016-06-15 18:58:12

标签: ios amazon-web-services amazon-s3 header aws-sdk-ios

我尝试将请求参数请求标头添加到我的传输实用程序上传表达式,以便充当我的元数据的持有者。

我正确地将它们添加到我的知识中并使用其记录的task.result上传显示测试标题,但是,当我检查Cloudwatch时,记录的事件记录不反映我的参数或标题。

以下是我的代码。我做错了什么?

    //create transfer utility

    AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];


    //create expression

    AWSS3TransferUtilityUploadExpression *myExpression = [AWSS3TransferUtilityUploadExpression new];


   //create key

    NSString *myKey = @"testUpload";


    //add request parameters to expression

    [myExpression setValue:@"video" forRequestParameter:@"filetype"];


    //add request headers to expression

    [expression setValue:@"test" forRequestHeader:@"x-amz-test"];


    //begin upload

    [[transferUtility uploadData:fileData
                          bucket:@"textapp"
                             key:myKey
                     contentType:@"binary/octet-stream"
                      expression:myExpression
                completionHander:nil] continueWithBlock:^id(AWSTask *task) {
        if (task.error) {
            NSLog(@"Error: %@", task.error);

            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An error occurred!"
                                                                message:@"Please try sending your message again."
                                                               delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
        }
        if (task.exception) {
            NSLog(@"Exception: %@", task.exception);

        }
        if (task.result) {
            //AWSS3TransferUtilityUploadTask *uploadTask = task.result;
            // Do something with uploadTask.
             NSLog(@"Upload was complete!");
        }

        return nil;
    }];

0 个答案:

没有答案