Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gsutil with google drive (not google cloud storage)

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

like image 258
RNZ Avatar asked Feb 19 '15 13:02

RNZ


People also ask

What is the difference between Google Cloud Storage and Google Drive?

With Google Cloud Storage you can upload/download a file, delete a file, obtain a list of files, or obtain the size of a given file. Google Drive, on the other hand, is used for storing personal files and it's free up to 15 GB across all your different personal services offered by Google.

Where can I use gsutil?

You can use gsutil to do a wide range of bucket and object management tasks, including: Creating and deleting buckets. Uploading, downloading, and deleting objects.

What is the difference between Gcloud and gsutil?

"gcloud" can create and manage Google Cloud resources while "gsutil" cannot do so. "gsutil" can manipulate buckets, bucket's objects and bucket ACLs on GCS(Google Cloud Storage) while "gcloud" cannot do so.


1 Answers

"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

like image 86
oleworldcoder Avatar answered Sep 20 '22 20:09

oleworldcoder