我正在努力通过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")
没有工作。
不要使用forRequestParameter使用forRequestHeader
的例子:
let expression = AWSS3TransferUtilityUploadExpression()
expression.setValue("max-age=3600", forRequestHeader: "Cache-Control")