如何在Google云端存储中获取文件的上次修改日期?

时间:2023-01-26 15:15:18

This guide on the Python library says cloudstorage.stat() returns

Python库上的这个指南说cloudstorage.stat()返回

... last-modified time, header-length, content type for the specified file.

...最后修改时间,标题长度,指定文件的内容类型。

The Java guide however, seems to have no counterpart. At least, I cannot find it in GcsFileMetadata.

然而,Java指南似乎没有对应的。至少,我在GcsFileMetadata中找不到它。

Is it possible to get this information using the Java library?

是否可以使用Java库获取此信息?

1 个解决方案

#1


0  

It seems the Java library doesn't have this feature (yet).

看来Java库还没有这个功能。

You can set this info manually, though:

您可以手动设置此信息:

GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
  .setBucket("my_bucket") 
  .setKey("my_object")
  .setAcl("public-read")
  .setMimeType("text/html") //etc etc
  .setUserMetadata("date-created", "01/09/2011", "owner", "Jon");

And retrieve this piece of metadata with

并使用。检索此元数据

GcsFileMetadata.getOptions().getUserMetadata().get("date-created")

#1


0  

It seems the Java library doesn't have this feature (yet).

看来Java库还没有这个功能。

You can set this info manually, though:

您可以手动设置此信息:

GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
  .setBucket("my_bucket") 
  .setKey("my_object")
  .setAcl("public-read")
  .setMimeType("text/html") //etc etc
  .setUserMetadata("date-created", "01/09/2011", "owner", "Jon");

And retrieve this piece of metadata with

并使用。检索此元数据

GcsFileMetadata.getOptions().getUserMetadata().get("date-created")