copy file from Google Drive to Google Cloud Storage within Google

前端 未结 2 629
囚心锁ツ
囚心锁ツ 2020-12-30 10:01

Is it possible to copy a file from Google Drive to Google Cloud Storage? I imagine it would be very fast since both are on a similar storage system.

I haven\'t seen

相关标签:
2条回答
  • 2020-12-30 10:38

    @frunkad commented a link to a nice workaround, but for completeness I will recite this here, as it is currently the top result in search.

    You can open a Colab (Juypiter Notebook on Google servers), mount your gDrive and use the gCloud CLI to copy files.

    1. open https://colab.research.google.com/ and connect to a machine
    2. Mount your Drive by executing the code below, clicking on the link and pasting the authentification key
    from google.colab import drive
    drive.mount(‘/content/drive’)
    
    1. Connect to your Google Cloude Storage. (Project id can be found here
    from google.colab import auth
    auth.authenticate_user()project_id = 'your-project-id'
    !gcloud config set project {project_id}
    !gsutil ls
    
    1. Copy files using gsutil. Use -m tag for multi-threading to increase speed. (There is a Subfolder called "My Drive" that you have to address in your mounted drive)
    bucket_name = 'your_bucket_name'
    !gsutil -m cp -r /content/drive/My\ Drive/Your-Data/* gs://{bucket_name}/
    
    

    Original Author Philip Lies

    Link to his colab: https://colab.research.google.com/drive/1Xc8E8mKC4MBvQ6Sw6akd_X5Z1cmHSNca

    0 讨论(0)
  • 2020-12-30 10:45

    There's no direct way to do this. You could write an App Engine or Compute Engine app that reads from Drive using its API and writes to GCS using its API.

    0 讨论(0)
提交回复
热议问题