Reputation: 1
I have some files and folders on GCS(Google Cloud Storage):
And I have some files and folders on Cloud Shell as well:
Now, I want to download and upload these files and folders between GCS and Cloud Shell:
Are there any ways to do that?
Upvotes: 0
Views: 1864
Reputation: 1
Hint:
gsutil cp gs://<GCS_Bucket_Name>/<File_Name> <Cloud_Shell_Directory>
This downloads "one file" on GCS to current directory on Cloud Shell:
gsutil cp gs://test.com/file1.json .
This downloads "two files" on GCS to current directory on Cloud Shell:
gsutil cp gs://test.com/file1.json gs://test.com/file2.txt .
This downloads "one file" and "one folder" on GCS to current directory on Cloud Shell:
(Hint-1: "-r" is needed to download folders)
(Hint-2: If a folder is empty, the folder is not downloaded)
gsutil cp -r gs://test.com/file1.json gs://test.com/folder1 .
Hint:
gsutil cp <Cloud_Shell_File> gs://<GCS_Bucket_Name>
This uploads "one file" on Cloud Shell to GCS:
gsutil cp file1.json gs://test.com
This uploads "two files" on Cloud Shell to GCS:
gsutil cp file1.json file2.txt gs://test.com
This uploads "one file" and "one folder" on Cloud Shell to GCS:
(Hint-1: "-r" is needed to upload folders)
(Hint-2: If a folder is empty, the folder is not uploaded)
gsutil cp -r file1.json folder1 gs://test.com
Upvotes: 0
Reputation: 862
You can download the objects from the buckets in the Cloud Storage using gsutil cp
command in the cloud shell:
gsutil cp gs://BUCKET_NAME/OBJECT_NAME SAVE_TO_LOCATION
Also, you can download the files using the console by clicking on the Download icon associated with the object and upload it to the cloud shell.
For more information, refer to the documentation.
Upvotes: 1