Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload Files with Space in Name on Google Cloud SDK Shell

I'm new to Google Cloud Storage, but have managed to find every answer to my questions online, but now I'm trying to upload files using the Google Cloud SDK and it works great for files with no spaces "this_file_001.txt" but if I try to upload a file with spaces "this file 001.txt" the system won't recognize the command. The command I'm using that works is

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

Now the same command with spaces doesn't work

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

Is there any way to accomplish this task?

Thanks in advance.

like image 601
Mr. Bacan Avatar asked Jul 09 '16 01:07

Mr. Bacan


2 Answers

Putting the argument into quotes should help. I just tried the commands below using Google Cloud Shell terminal and it worked fine:

$ 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

That said, I'd avoid file names with spaces if I could.

like image 197
Alexey Alexandrov Avatar answered Nov 15 '22 15:11

Alexey Alexandrov


Alexey's suggestion about quoting is good. If you're on Linux or a Mac, you can likely also escape with a backslash (). On Windows, you should be able to use a caret (^).

Linux example:

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

Windows example:

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

Quotes work for both platforms, I think.

like image 27
Brandon Yarbrough Avatar answered Nov 15 '22 14:11

Brandon Yarbrough