通过AWSS3TransferUtility
(AWS-iOS-SDK v2.4.x)上传图片时,我很难定义缓存控制。
我的简化用法如下:
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
// ...
}
我目前关注的是表达方式,但expression.setValue("max-age=3600", forRequestParameter: "Cache-Control")
之类的调用并不起作用。
答案 0 :(得分:0)
请勿使用 forRequestParameter 使用 forRequestHeader
示例:
let expression = AWSS3TransferUtilityUploadExpression()
expression.setValue("max-age=3600", forRequestHeader: "Cache-Control")