【问题标题】:How to set Cache-Control in Java when inserting file to GS bucket?将文件插入 GS 存储桶时如何在 Java 中设置 Cache-Control?
【发布时间】:2015-02-04 20:31:39
【问题描述】:

我正在通过 Java API 通过 Storage.Objects.Insert 实例将我的文件上传到 Google Cloud Storage。

一切正常,我可以设置我的 ACL 等,但我不确定如何在我上传的文件上设置元数据。主要是想扩展“Cache-Control”标头。

Insert 对象上有一个 set 方法,但没有记录在案,我不确定它在做什么。

我正在寻找一个 Java 等价于:

gsutil setmeta -h "Cache-Control:public, max-age=31536000" gs://{my_bucket}/{my_file}

而且我希望通过Insert对象上传文件的时候有办法设置这个header。

非常感谢任何帮助。

【问题讨论】:

    标签: google-cloud-storage google-api-java-client


    【解决方案1】:

    请参阅sample code here 以使用 Java API 插入对象。请注意,它提供了一个 StorageObject 类,其中有一个您可以使用的 setCacheControl 标头。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-10
      • 2021-03-15
      • 1970-01-01
      • 2019-01-20
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多