0

I'm struggling to define cache control when uploading images via the AWSS3TransferUtility (AWS-iOS-SDK v2.4.x).

My simplified usage is like:

let utility = AWSS3TransferUtility.S3TransferUtilityForKey("key")
let data = UIImageJPEGRepresentation(image, 0.9)!

let expression = AWSS3TransferUtilityUploadExpression()
expression.progressBlock = { (task, progress) in
    onProgress?(progress: progress.fractionCompleted)
}

transferUtility.uploadData(data, bucket: GlobalConfig.awsS3DefaultBucket, key: "image.jpeg", contentType: "image/jpeg", expression: expression) { (task, error) in
    // ...
}

My current focus was on the expression, but calls like expression.setValue("max-age=3600", forRequestParameter: "Cache-Control") didn't work.

Carsten
  • 1,029
  • 14
  • 29
  • using `expression.setValue("max-age=3600", forRequestParameter: "Cache-Control")` should work. Try downloading the content and see if you get the cache-control header in the response. – Karthik Jul 22 '16 at 15:42
  • Thanks for the reply but as I wrote, it is not working. Neither `curl` nor directly checking the bucket shows any additional headers. However, I can manually add headers in S3 and get them via `curl` :-/ – Carsten Jul 22 '16 at 17:23

1 Answers1

1

Do not use forRequestParameter use forRequestHeader

example:

let expression = AWSS3TransferUtilityUploadExpression()
expression.setValue("max-age=3600", forRequestHeader: "Cache-Control")
Zigglzworth
  • 6,645
  • 9
  • 68
  • 107
  • I'm not working on that project anymore, but now with some distance it looks quite obvious to use the request *header* instead of the parameter. – Carsten May 12 '19 at 22:02