我们可以通过linux shell脚本或python将文件上传到谷歌文档

时间:2011-05-29 07:37:42

标签: file-upload google-docs

是否可以通过命令行或bash或python将文件上传到Google文档。我有很多东西需要上传,但我只能访问命令行而没有别的。

有办法吗

3 个答案:

答案 0 :(得分:6)

绝对。你需要Google Docs API。 Python应该做得很好。还有一堆来自Google here的示例代码,其示例仅执行此操作here

答案 1 :(得分:0)

对于bash访问,这是用于挂载Google文档的有用的FUSE驱动程序:

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

Google为gdata API提供了一个python客户端:

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

还有一些有用的python脚本可以提供类似bash的命令来访问Google Docs:

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

答案 2 :(得分:0)

查看以下内容:https://github.com/prasmussen/gdrive

对于Ubuntu,请使用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