如何使用Google API在Google Storage上创建一个空文件夹?

问题描述:

如何使用Google API在Google Storage上创建一个空文件夹? (假设/是路径分隔符.)

How to create an empty folder on Google Storage with Google API? (Assume that / is path separator.)

Google Cloud Storage没有文件夹或子目录.但是,有一些模拟它们的支持. gsutil的子目录的工作原理是一些背景知识的好阅读.

Google Cloud Storage does not have folders or subdirectories. However, there is some support for emulating them. gsutil's How Subdirectories Work is a good read for some background.

Google Cloud Storage对象是一个平面命名空间,但是许多工具(包括gsutil和Google Cloud Storage UI)都产生了层次结构文件树的错觉.

Google Cloud Storage objects are a flat namespace, but many tools, including gsutil and the Google Cloud Storage UI, create an illusion of a hierarchical file tree.

创建空子目录的错觉有两种广泛使用的约定:

There are two widely used conventions for creating the illusion of an empty subdirectory:

  1. (推荐)创建一个以斜杠结尾的对象.例如,要在存储桶的根目录创建一个名为foo的子目录,您将创建一个名为foo/的空对象(大小为0).

  1. (recommended) Create an object that ends in a trailing slash. For example, to create a subdirectory called foo at the root of a bucket, you would create an empty object (size 0) called foo/.

(旧版)创建一个对象,并在名称后附加_$folder$.例如,要在存储桶的根部创建一个名为foo的子目录,您将创建一个名为foo_$folder$的空对象(大小为0).

(legacy) Create an object with _$folder$ appended to the name. For example, to create a subdirectory called foo at the root of a bucket, you would create an empty object (size 0) called foo_$folder$.

请注意,大多数工具和实用程序现在都在使用方法1.方法2的使用频率较低.

Note that most tools and utilities are using method 1 now. Method 2 is less frequently used.