Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank custom metadata when uploading file to AWS S3 using iOS SDK

I'm uploading a file to S3 from iOS using AWSS3TransferUtility and trying to set come custom metadata on the file. I'm testing it using the metadata key X-Amz-Meta-uploadParameters and the value "Test".

It appears correctly in the request headers:

... &X-Amz-Expires=2999&X-Amz-Meta-uploadParameters=Test&X-Amz-Security-Token= ...

Something is clearly happening, since after upload the key uploadparameters does appear in the object's properties in the S3 console, but with a blank value. To double-check I used s3api --head-object from the CLI and here's what's returned:

{
    "AcceptRanges": "bytes",
    "LastModified": "Thu, 16 Mar 2017 08:04:41 GMT",
    "ContentLength": 1331730,
    "ETag": "\"[hex data here]\"",
    "ContentType": "image/jpeg",
    "Metadata": {
        "uploadparameters": ""
    }
}

Here's how I'm setting the value up for the AWSS3TransferUtilityUploadExpression:

        let params = [
            "X-Amz-Meta-uploadParameters": "Test"
        ]

        //Copy the custom Meta information into the expression
        for (key, value) in params {
            expression.setValue(value, forRequestParameter: key)
        }

Having played around with all kinds of variations I'm still no closer to setting actual metadata. What am I missing here?

like image 901
Jonathan Avatar asked Dec 13 '25 13:12

Jonathan


1 Answers

Fixed. After posting this question I continued tweaking things in frustration and stumbled across the answer.

Altering the key to all lower case is the magic twist, i.e. x-amz-meta-uploadparameters rather than X-Amz-Meta-uploadParameters. Incidentally, it also fails with X-Amz-Meta-uploadparameters.

like image 165
Jonathan Avatar answered Dec 15 '25 05:12

Jonathan