Hello everyone. I'm a beginner to Python and I've decided to start a project to help me learn the language. Since I could not find an easy way to upload files to Google Docs from the desktop, I figured that I could help both myself and the community by attempting to create one. At the moment I have a very basic prototype that asks for authentication info and the full path of a file, while checking and outputting the content-type to the Google Docs server. I'd like to add some basic user input checks and possibly migrate it over to PyGTK with more features, such as a list of all files, a delete function, mass upload, and possibly download. If anyone could help me that'd be great, as I am completely lost with PyGTK.
Here's the script I have so far:
Code:
from gdata.docs import service
import mimetypes
def create_client():
client = service.DocsService()
client.email = raw_input("Enter your Google Account e-mail address: ")
client.password = raw_input("Enter your Google Account password: ")
client.ProgrammaticLogin()
return client
def upload_file():
import gdata
file_path = raw_input("Please enter the full path of the file you wish to upload: ")
title = raw_input("What would you like to name this file? ")
type = mimetypes.guess_type(file_path)
ms = gdata.MediaSource(file_path = file_path, content_type = type[0])
client = create_client()
entry = client.UploadDocument(ms,title)
print 'Link:', entry.GetAlternateLink().href
upload_file()
Bookmarks