java - 使用 AWS Java SDK 设置 Expires 和其他杂项 HTTP header

标签 java amazon-s3 amazon-web-services

我的一些用户使用的是不支持 Cache-Control HTTP header 的旧浏览器。因此,除了确保我的内容在可能的情况下被缓存之外,我还想设置 Expires header 。

我正在使用 Java SDK,我发现 this question也就是说上传时使用ObjectMetadata中的setHeader方法。

这似乎工作正常,但我注意到在 JavaDocs 中它声明 setHeader 方法仅供内部使用。从我自己的代码中调用此方法可能会出现任何问题吗?

最佳答案

This seems to work OK, but I notice that in the JavaDocs it states that the setHeader method is for internal use only. Are there any problems that may arise from calling this method from my own code?

这个有点令人惊讶的问题已经再次出现,请参阅 bkirkbri's comment - 这是 my reply :

Hmmh, I wasn't aware of that restriction indeed, but recall having used Expires: at some point a while back; I might be wrong though, insofar I often use other SDKs for interacting with S3 (e.g. C#/Python, which do definitely support this) and could have mixed that up - the code itself doesn't differ from the other setXYZHeader() methods currently (see ObjectMetadata.java), so the restriction would be based on a non visible side effect, if any.

这似乎仍然成立,即如果您分析代码,则没有任何其他迹象 - 因此,bkirkbri's conclusion似乎正确地总结了事态:

It's probably used by the other header methods internally and internal only because only certain headers will work. They should add a setExpires method on ObjectMetadata as it's the only header that doesn't have it's own method

除此之外,恐怕只有 AWS SDK for Java 团队本身才能提供明确的答案:像往常一样,您可能会在相应的 AWS forum 中询问。 ,但截至最近,他们正在接受移动 GitHub repository 中的问题同样,这可能会为此类与代码相关的问题提供更快、更明确的结果。

关于java - 使用 AWS Java SDK 设置 Expires 和其他杂项 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13792227/

相关文章:

amazon-web-services - Elasticsearch增量执行快照

java - HTTP 404 - 没有映射与上下文路径 [/FormularioMD] 关联的命名空间 [/modeldriven] 和操作名称 [datosUsuario] 的操作

java - HSSFCell - 确定什么类型的数字

java - 编写大 JSON 文件避免内存不足问题的最佳方法

ruby-on-rails - 针对单个存储桶的读写权限的 AWS S3 IAM 策略

amazon-web-services - 如何签署 CSR 以在 AWS ACM 中启用私有(private)证书颁发机构 (CA)? (如何生成版本3证书?)

java - 将 Equinox 3.2.1 嵌入到 WebSphere 中

java - 在jsp中使用jtable为所有表添加分页

Hadoop distcp 命令使用不同的 S3 目标

php - 将 AMI 从单独的账户复制到单独的区域