如何从GCS获取文件元数据 [英] how to get file metadata from GCS

查看:87
本文介绍了如何从GCS获取文件元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取存储在Google Cloud Storage中的文件的文件元数据.实际上,我们需要文件的媒体链接,以便可以下载文件或将URL添加到页面进行下载.

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);

例如,我正在使用公共存储桶,但是blob包含 metadata = null .有什么方法可以获取文件元数据?

I am using public bucket, for example, but blob contains metadata=null. Is there any way to get file metadata?

谢谢

推荐答案

此处提供GCP支持!我测试了代码,它工作正常.事实是,当您搜索对象元数据时,它返回存储桶的对象元数据,而不是文件元数据本身.

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.

这篇关于如何从GCS获取文件元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆