将文件从 Google Drive 复制到 Google 内的 Google Cloud Storage [英] copy file from Google Drive to Google Cloud Storage within Google
问题描述
是否可以将文件从 Google Drive 复制到 Google Cloud Storage?我想这会非常快,因为两者都在类似的存储系统上.
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.
我还没有看到任何关于无缝执行此操作的信息,无需下载文件(可能到谷歌系统外的系统)然后重新上传.大约一年前,有人问过一个类似的问题:从保管箱/驱动器到 Google 云存储.
I haven't seen any information on either ways to do this seamlessly, without having to download the file (probably to an out-of-google system) and then re-uploading it. About one year ago, a similar question was asked: Transfer files from dropbox/drive to Google cloud storage.
有没有办法直接执行此操作,并且文件一直保留在 Google 中?
Is there a way to do this directly, with the file staying within-Google the entire time?
推荐答案
@frunkad 评论了一个很好的解决方法的链接,但为了完整起见,我将在此处引用它,因为它目前是搜索中的最高结果.
@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.
您可以打开 Colab(Google 服务器上的 Juypiter Notebook),挂载您的 gDrive 并使用 gCloud CLI 复制文件.
You can open a Colab (Juypiter Notebook on Google servers), mount your gDrive and use the gCloud CLI to copy files.
- 打开 https://colab.research.google.com/ 并连接到一台机器
- 通过执行以下代码、点击链接并粘贴验证密钥来安装您的云端硬盘
from google.colab import drive
drive.mount(‘/content/drive’)
- 连接到您的 Google 云存储.(可以在此处找到项目 ID)
- Connect to your Google Cloud 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
- 使用 gsutil 复制文件.使用 -m 标签进行多线程以提高速度.(您必须在安装的驱动器中找到一个名为我的驱动器"的子文件夹)
bucket_name = 'your_bucket_name'
!gsutil -m cp -r /content/drive/My Drive/Your-Data/* gs://{bucket_name}/
原作者 菲利普的谎言
链接到他的 colab:https://colab.research.google.com/drive/1Xc8E8mKC4MBvQ6Sw6akd_X5Z1cmHSNca
Link to his colab: https://colab.research.google.com/drive/1Xc8E8mKC4MBvQ6Sw6akd_X5Z1cmHSNca
这篇关于将文件从 Google Drive 复制到 Google 内的 Google Cloud Storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!