问题
I would like to get file meta data of file stored in Google Cloud Storage. Actually we require a media link of file so file can be downloaded or url added to page for download.
Blob blob = storage.get("gcp-public-data-nexrad-l2", "1991/06/05/KTLX/NWS_NEXRAD_NXL2LG_KTLX_19910605160000_19910605235959.tar");
ReadChannel readChannel = blob.reader();
System.out.println(blob);
I am using public bucket, for example, but blob contains metadata=null
. Is there any way to get file metadata?
Thanks
回答1:
GCP Support here! I tested the code and it’s working fine. The thing is that when you search for an object metadata it returns the bucket’s object metadata, not the file metadata itself.
You can make a quick test by going to the bucket and adding metadata to the object. To do so, you need to click on the three vertical dots icon of a file and edit metadata. Then you can run the code and you’ll see under "metadata" all the values you just added.
Here’s a useful doc about it.
来源:https://stackoverflow.com/questions/49683255/how-to-get-file-metadata-from-gcs