如何使用 Google API 在 Google Storage 上创建一个空文件夹? [英] How to create an empty folder on Google Storage with Google API?
问题描述
如何使用 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 用户界面)会产生分层文件树的错觉.
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:
(推荐) 创建一个以斜杠结尾的对象.例如,要在存储桶的根目录创建一个名为
foo
的子目录,您将创建一个名为foo/
的空对象(大小为 0).
(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) calledfoo/
.
(legacy) 创建一个在名称后附加 _$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.
这篇关于如何使用 Google API 在 Google Storage 上创建一个空文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!