top of page

[Tech Talk] Cloud: An Easy Way to Copy Files From Google Drive to Cloud Storage

You can sync files between Google Drive and Google Cloud Platform by using simple codes in Google's Colab with just 3 steps



Let's get started!

  1. Connect Colab to Google Drive: from google.colab import drive drive.flush_and_unmount() drive.mount('/content/drive/', force_remount=True) In this step, you will need to login Google Drive account and copy authentication key back to Colab. Then, you will get connected and see all your Drive folders and files.

  2. Connect Colab to GCP: from google.colab import auth auth.authenticate_user() project_id = 'YOUR-PROJECT_ID' !gcloud config set project {project_id} !gsutil ls In this step, you will need to login GCP account and copy authentication key back to Colab. Then, you will get connected and see all your buckets.

  3. Copy assigned Google Drive files to Cloud Storage on GCP: bucket_name = 'YOUR-STORAGE-BUCKET-NAME' !gsutil -m cp -r /content/drive/MyDrive/$YOUR-DRIVE-PATH gs://$YOUR-GCP-BUCKET-PATH After you finish filling in your own info and run it, you can see the assigned files are copying from Google Drive to GCP. Wait a few minutes, ALL DONE!

Isn't it very easy? Feel free to leave a comment or contact us if you have any further questions.

Comments


bottom of page