gsutil – Upload and Download file Google Cloud Storage Bucket using command line

gsutil Upload Download file Google Storage Bucket

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.

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.

Upload Download file Google Storage Bucket
TheCodeBuzzpng

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.

Upload Download file Google 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

Upload file Google Storage Bucket

Once the command is successful, you shall see the file generated in the path.

Download file Google Storage Bucket

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.



2 thoughts on “Upload, Download file Google Storage Bucket using gsutil

  1. 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??

Leave a Reply

Your email address will not be published. Required fields are marked *