将 gsutil 与谷歌驱动器(不是谷歌云存储)一起使用

2024-05-11

gsutil https://cloud.google.com/storage/docs/gsutil?csw=1#gettingstarted use 博托配置文件 https://cloud.google.com/storage/docs/gsutil_install#config用于在 Google Cloud Storage 进行身份验证。

我在 console.developers.google.com 中生成 ClientID - 允许通过 python 脚本将文件放入 Google Drive:

#!/usr/bin/env python

from apiclient.discovery import build
from apiclient.http import MediaFileUpload
import httplib2
from oauth2client.client import SignedJwtAssertionCredentials

credentials = SignedJwtAssertionCredentials(
service_account_name='301714561983-nkd8kalz1op3bdjn75ija1b7ef1sslpr@developer.gserviceaccount.com',
private_key='''-----BEGIN PRIVATE KEY-----
приватный ключик 
-----END PRIVATE KEY-----''',
        scope = [
                'https://www.googleapis.com/auth/drive',
                'https://www.googleapis.com/auth/drive.file',
                'https://www.googleapis.com/auth/drive.appdata',
                'https://www.googleapis.com/auth/drive.apps.readonly'
        ]
)

http = httplib2.Http()
http = credentials.authorize(http)

drive_folder_id = '0C3ZU6kySEIuCT0ANM3RRVE1iME0' #folder id

service = build('drive', 'v2', http=http)

media_body = MediaFileUpload('document.txt')
body = {
        'title': 'document.txt',
        'description': 'backup',
        'mimeType': 'text/plain',
        'parents': [{'id': drive_folder_id}]
}

file = service.files().insert(
        body=body,
        media_body=media_body).execute()

我想用gsutil rsync用于将我的数据与 Google 云端硬盘同步。 有人知道如何配置 boto 配置以在 Google Drive 进行身份验证吗?如果可能的话,该怎么做?

目前我使用 ClientID (gsutil config -e) 来发现对谷歌云存储的访问:

$ gsutil ls gs://uspto-pair/applications/0800401*
gs://uspto-pair/applications/08004010.zip
gs://uspto-pair/applications/08004011.zip
gs://uspto-pair/applications/08004012.zip
gs://uspto-pair/applications/08004013.zip
gs://uspto-pair/applications/08004016.zip
gs://uspto-pair/applications/08004017.zip
gs://uspto-pair/applications/08004019.zip

但我无法访问文件夹(通过路径或文件夹 ID)。可能有人知道用于访问 Google Drive 上的文件夹的 uri 格式(没有存储桶或使用 Google Drive 的某些默认存储桶)?


“可能有人知道用于访问 Google 云端硬盘上的文件夹的格式 URI(没有存储桶或带有 Google 云端硬盘的某些默认存储桶)?”

===================================

作者:

• 网络鸭子

• Grive

• InSync

知道如何访问 Google 云端硬盘,这是肯定的。其中两个是开源软件:

https://cyberduck.io/ https://cyberduck.io/

https://www.insynchq.com/downloads https://www.insynchq.com/downloads

http://www.howtogeek.com/130380/how-to-use-google-drive-on-linux-2-unofficial-solutions/ http://www.howtogeek.com/130380/how-to-use-google-drive-on-linux-2-unofficial-solutions/

http://www.webupd8.org/2012/05/grive-open-source-google-drive-client.html http://www.webupd8.org/2012/05/grive-open-source-google-drive-client.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将 gsutil 与谷歌驱动器(不是谷歌云存储)一起使用 的相关文章

随机推荐