我有一个现有的Google App Engine Python应用程序,它具有很多功能.我现在想要将Google云端硬盘集成到应用中.具体来说,我希望我的应用能够:
如果有人知道如何做我想做的事情,可以将我引导到符合我的SPECIFIC要求的SPECIFIC Google网页(不是像"DrEdit示例"这样的一般答案),我将永远感激不尽. .提前致谢!
更新:
根据drive-v2-python-appengine在答案1中的建议生成的示例代码,这是我的程序,其中包含用于创建空文件的RequestHandler:
import os
import webapp2
import io
from google.appengine.api import memcache
import httplib2
from apiclient.discovery import build
from apiclient.http import MediaIoBaseUpload
from oauth2client.appengine import oauth2decorator_from_clientsecrets
decorator = oauth2decorator_from_clientsecrets(
os.path.join(os.path.dirname(__file__), 'client_secrets.json'),
scope=[
'https://www.googleapis.com/auth/drive',
])
http = httplib2.Http(memcache)
drive_service = build("drive", "v2", http=http)
class CreateEmptyFile(webapp2.RequestHandler):
@decorator.oauth_required
def get(self):
body = {
'title': 'Sample Document',
'description': 'A sample document',
'mimeType': 'text/plain'
}
media_body = MediaIoBaseUpload(io.BytesIO(""), mimetype='text/plain', resumable=True)
file = drive_service.files().insert(body=body, …Run Code Online (Sandbox Code Playgroud)