gsutil – Upload and Download file Google Cloud Storage Bucket using command line
Today in this article we shall see how to perform Upload, Download file Google Storage Bucket using gsutil
gsutil is actually a Python command-line application that lets you access Cloud Storage.
You can use gsutil to perform a lot of operations including uploads and downloads etc. using HTTPS and transport-layer security (TLS) etc.
WE shall cover below aspects in this article,
Quickstart
Prerequisites
- Create an account in the google cloud project.
- Install the Google Cloud SDK
Upload the File/Object to google Bucket using gsutil command line
Let’s use the below image(the official logo of the TheCodebuzz) as an example.
We shall be uploading this file to the GCP bucket.
Let’s save the above file to the computer in the path C:\test\thecodebuzz.png
Command Pattern
gsutil cp [target-file-path] gs://[gcs-path]
Example
gsutil cp C:\test\thecodebuzz.png gs://thecodebuzz/load-from-gcutil
After the successful execution of the commands file will be uploaded to the google cloud storage bucket.
Note : Command will overwrite any existing file.
Download File/Object from google Bucket using gsutil command line
We shall now download the above-uploaded file from google Bucket using gsutil command line as below,
Command Pattern
gsutil cp gs://[gcs-path] [target-file-path]
Example
gsutil cp gs://thecodebuzz/load-from-gcutil/thecodebuzz.png C:\Test\gcp\Download
Once the command is successful, you shall see the file generated in the path.
Move/Archive files from google Bucket using gsutil command line
Please visit the below article for more details,
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
References :
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.
How to do multiple files download from a bucket to same location like we have a bucket of organization having 100 users emails to download in local storage …how to do that??
Hi Mudassar, You could try using PowerShell script with gsutil (for better control on file access). Please refer to this article – Powershell Upload, Download file Google Cloud Storage Bucket