13

Is it possible to upload files to google docs via commandline or bash or via python. i have plent of stuff to upload but i have only access to command line and shh nothing else.

is there way to do

Mirage
  • 30,868
  • 62
  • 166
  • 261

3 Answers3

6

Absolutely. You'll need the Google Docs API. Python should do a lovely job. There is also a bunch of example code from Google here with examples doing just this here.

Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
  • Basically i have flv videos which i want to upload . they have now allowed videos as well. so will that work in that case – Mirage May 29 '11 at 07:46
  • 1
    It's unclear to me how one can log in without using email/password. There's no way I'm going to put my real account credentials into a script. I don't see any way to add google Docs via the API console either. There are no examples of doing OAuth based auth to docs that I can find. – slacy Apr 24 '12 at 19:50
  • https://developers.google.com/google-apps/documents-list/#creating_and_uploading_documents_and_files – Charlie Martin Apr 25 '12 at 20:21
0

Check this out: https://github.com/prasmussen/gdrive

For Ubuntu use gdrive-linux-x64:

$ wget -O gdrive "https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA&export=download"

$ chmod +x gdrive

$ echo "Hello World" > hello.txt

$ ./gdrive upload hello.txt
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=##########
Enter verification code: 4/Zg#############er234

Uploading hello.txt
Uploaded 1g#############qU2 at 6.0 B/s, total 12.0 B

$ ./gdrive info 1g#############qU2
Id: 1g#############qU2
Name: hello.txt
Path: hello.txt
Mime: text/plain
Size: 12.0 B
Created: 2018-09-25 13:47:24
Modified: 2018-09-25 13:47:24
Md5sum: e59ff97941044f85df5297e1c302d260
Shared: True
Parents: 0AL#############3VA
ViewUrl: https://drive.google.com/a/positrace.com/file/d/1g#############qU2/view?usp=drivesdk
DownloadUrl: https://drive.google.com/a/positrace.com/uc?id=1g#############qU2&export=download
  • Seems that Google didn't authorized this app to connect, as of today: tried with `gdrive-linux-x64` release, didn't work, unable to get the authorization code. – kebs Feb 18 '20 at 15:54
0

For bash access, this is a useful FUSE driver for mounting Google Docs:

http://code.google.com/p/google-docs-fs/

Google provides a python client to the gdata APIs:

http://code.google.com/p/gdata-python-client/

And there are some useful python scripts that provide bash-like commands to access Google Docs:

http://code.google.com/p/gdatacopier/

resplin
  • 436
  • 5
  • 12