【问题标题】:Using gsutil with google drive (not google cloud storage)将 gsutil 与谷歌驱动器一起使用(不是谷歌云存储)
【发布时间】:2015-04-20 20:34:47
【问题描述】:

gsutil 使用 boto configuration file 在 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 config 以在 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)。可能是任何已知格式 uri 用于访问 Google Drive 上的文件夹(没有存储桶或 Google Drive 的一些默认存储桶)?

【问题讨论】:

  • 你解决过这个问题吗?

标签: authentication google-drive-api rsync gsutil


【解决方案1】:

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

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

作者:

• Cyber​​Duck

• 悲伤

• 同步

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

https://cyberduck.io/

https://www.insynchq.com/downloads

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

【讨论】:

【解决方案2】:

gsutil 工具专用于访问文件,将文件放在 Google Cloud Storage 的存储桶中。

【讨论】:

  • 我知道,但是 ClientID(在 console.developers.google.com 中生成)可以访问存储桶(通过 gsutil)和谷歌驱动器(通过 python)。我认为/希望谷歌驱动器也有“桶”。
猜你喜欢
  • 2014-09-13
  • 2020-09-10
  • 2022-12-03
  • 2023-02-06
  • 2015-07-17
  • 2016-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多