在 Google Cloud SDK Shell 上上传名称为 Space 的文件

Upload Files with Space in Name on Google Cloud SDK Shell

我是 Google Cloud Storage 的新手,但我已经设法在网上找到了我的问题的所有答案,但现在我正在尝试使用 Google Cloud SDK 上传文件,它对于没有空格 "this_file_001.txt" 的文件非常有效,但如果我尝试上传带有空格 "this file 001.txt" 的文件,系统将无法识别该命令。我正在使用的有效命令是

gsutil -m cp -r this_file_001.txt gs://this_file_001.txt

现在带空格的相同命令不起作用

gsutil -m cp -r this file 001.txt gs://this file 001.txt

有什么方法可以完成这个任务吗?

提前致谢。

将参数放在引号中应该会有帮助。我刚刚使用 Google Cloud Shell terminal 尝试了下面的命令,它运行良好:

$ gsutil mb gs://my-test-bucket-55 Creating gs://my-test-bucket-55/... $ echo "hello world" > "test file.txt" $ gsutil cp "test file.txt" "gs://my-test-bucket-55/test file.txt" Copying file://test file.txt [Content-Type=text/plain]... Uploading gs://my-test-bucket-55/test file.txt: 12 B/12 B $ gsutil cat "gs://my-test-bucket-55/test file.txt" hello world

也就是说,我会尽可能避免使用空格的文件名。

A​​lexey 关于引用的建议很好。如果您使用 Linux 或 Mac,您也可以使用反斜杠 () 进行转义。在 Windows 上,您应该可以使用插入符号 (^)。

Linux 例子:

$> gsutil cp test\ file.txt gs://bucket

Windows 示例:

c:\> gsutil cp test^ file.txt gs://bucket

我认为报价适用于两个平台。