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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With