设置缓存控制 header 不适用于 S3

set cache control header not working for S3

我试图在 S3 上传时将缓存控制设置为 no-cache,但未设置 header。我在上传脚本中尝试了以下内容,但没有用。

request: {
            endpoint: "https://",
            accessKey: "",
            customHeaders: "Cache-Control: no-cache"
        },

然后我也尝试像这样将它添加到 S3 处理程序 php 文件中(添加到底​​部)

 // Only needed in cross-origin setups
function handlePreflight() {
 handleCorsRequest();
 header('Access-Control-Allow-Methods: POST');
 header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Headers: Cache-Control');

另外我也把它加在这里

function signRequest() {
header('Content-Type: application/json');
header('Cache-Control: no-cache');

无论是他们自己还是他们一起使 header 出现在上传的文件中。

所以我不确定我做错了什么

您最后两个示例不会对 S3 中的 object 产生任何影响。相反,它们只会影响对 Fin Uploader 签名请求的响应。您的第一个示例格式不正确。 request.customHeaders 选项需要一个 object 值。

无论如何,您目前无法通过 Fine Uploader S3 将这些类型的 headers 传递到 S3 object。有关详细信息和更新,请参阅 https://github.com/FineUploader/fine-uploader/pull/1258

为 S3 设置自定义 headers。使用 'request.params' 而不是 'request.customHeaders'。 例如(在这种情况下尝试使用下面的)


request: {
            endpoint: "https://endpoint.url.here",
            accessKey: "access-key-here",
            params: {"Cache-Control": "no-cache"}
        },


要了解更多信息,请参阅 docs.