使用gsutil列出存储桶中所有对象的所有公共链接 [英] Listing all public links for all objects in a bucket using gsutil

查看:72
本文介绍了使用gsutil列出存储桶中所有对象的所有公共链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使用 Cloud SDK的 Google Cloud Storage 存储桶(或存储桶中的目录)中的所有对象的所有公共链接> gsutil 或 gcloud ?

Is there a way to list all public links for all the objects stored into a Google Cloud Storage bucket (or a directory in a bucket) using Cloud SDK's gsutil or gcloud?

类似的东西:

$ gsutil ls --public-link gs://my-bucket/a-directory

$ gsutil ls --public-link gs://my-bucket/a-directory

推荐答案

公开可见对象的公共链接是可预测的.它们只符合以下模式: https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME .

Public links for publicly visible objects are predictable. They just match this pattern: https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME.

gsutil没有命令来为存储桶中的对象打印URL,但是它只能列出对象.您可以将其通过管道传输到sed之类的程序,以将这些列表替换为对象名称.例如:

gsutil doesn't have a command to print URLs for objects in a bucket, but it can just list objects. You could pipe that to a program like sed to replace those listings with object names. For example:

gsutil ls gs://pub/** | sed 's|gs://|https://storage.googleapis.com/|'

这里的缺点是,这将产生指向所有资源的链接,而不仅仅是指向公开的资源.因此,您需要知道哪些资源是公开可见的,或者您需要基于 gsutil ls -L 编写更详细的过滤器.

The downside here is that this would produce links to all resources, not just those that are publicly visible. So you'd need to either know which resources are publicly visible, or you'd need to write a more elaborate filter based on gsutil ls -L.

这篇关于使用gsutil列出存储桶中所有对象的所有公共链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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