Reputation: 3396
I can't find a way to set metadata using this library: Amazon S3 Transfer Utility for iOS
Is there a way to achieve this?
Upvotes: 1
Views: 1407
Reputation: 578
You can assign user-defined metadata to an object. User-defined metadata must begin with the prefix "x-amz-meta-", otherwise Amazon S3 will not set the key value pair as you define it. You define custom metadata by adding a name that you choose to the x-amz-meta- key. This creates a custom key. For example, if you add the custom name alt-name, the metadata key would be x-amz-meta-alt-name.
You can refer this link : https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-object-metadata.html#add-object-metadata-user-defined
var uploadCompletion: AWSS3TransferUtilityUploadCompletionHandlerBlock?
uploadCompletion = { (uploadTask, error) in
if error == nil {
completion(nil)
} else {
completion(error)
}
}
let expression = AWSS3TransferUtilityUploadExpression()
//YOUR METADATA HERE
expression.setValue("value", forRequestParameter: "x-amz-meta-yourkeyhere")
let transferUtility = AWSS3TransferUtility.default()
transferUtility.uploadData(data,
bucket: s3BucketName,
key: key,
contentType: "image/png",
expression: expression,
completionHandler: uploadCompletion)
Upvotes: 3
Reputation: 3759
You can use - setValue:forRequestParameter:
on AWSS3TransferUtilityExpression
to add metadata.
Note Amazon S3 stores user-defined metadata in lowercase. Each name, value pair must conform to US-ASCII.
Upvotes: 2