Using gsutil with google drive (not google cloud storage)
Asked Answered
K

2

6

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)?

Kingcup answered 19/2, 2015 at 13:15 Comment(1)
did you ever resolve this?Syndactyl
S
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

Spleenwort answered 4/4, 2015 at 4:47 Comment(1)
Actually, CyberDuck only mentions "Google Cloud Storage" trac.cyberduck.io/wiki/help/en/howto/cli but the other two (Grive and InSync) claim to support Google Drive.Spleenwort
B
0

gsutil tool is specific for Accessing files, putting files on buckets in Google Cloud Storage.

Bujumbura answered 20/2, 2015 at 20:50 Comment(1)
I know, but ClientID (generated in console.developers.google.com) have access to both - to buckets (by gsutil) and to google drive (by python). And I think/hope google drive have 'buckets' too.Kingcup

© 2022 - 2024 — McMap. All rights reserved.