Вопрос

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

... 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.

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

Это было полезно?

Решение

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

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")
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top