2

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

我将它们正确添加到我的知识中,并使用其记录的 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;
    }];
4

0 回答 0