Using gsutil with google drive (not google cloud storage)

坚强是说给别人听的谎言 提交于 2019-12-11 02:35:29

问题


gsutil use boto configuration file for authenticate at Google Cloud Storage.

I generate ClientID in console.developers.google.com - that allow put files to Google Drive by python script:

#!/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()

And I want use gsutil rsync for sync my data with Google Drive. Anybody known about configure boto config for authenticate at Google Drive? How to do this, if this possible?

Currently I use ClientID (gsutil config -e) for discover access to google cloud storage:

$ 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

but i can't access to folder (by path or by folder ID). May be anybody known format uri for access to folders on Google Drive (with out bucket or with some default bucket for Google Drive)?


回答1:


"May be anybody knows format URI for accessing folders on Google Drive (without bucket or with some default bucket for Google Drive)?"

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

The authors of:

• CyberDuck

• Grive

• InSync

Know how to access Google Drive, that's for sure. Two of them are Open Source Software:

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 tool is specific for Accessing files, putting files on buckets in Google Cloud Storage.



来源:https://stackoverflow.com/questions/28607388/using-gsutil-with-google-drive-not-google-cloud-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!