相关疑难解决方法(0)

从Google App Engine Python应用访问Google云端硬盘

我有一个现有的Google App Engine Python应用程序,它具有很多功能.我现在想要将Google云端硬盘集成到应用中.具体来说,我希望我的应用能够:

  1. 在我的用户的Google云端硬盘中创建一个空文件,我的用户可以在其中创建Google文档.
  2. 从Google云端硬盘中检索该文件,以便在我的应用中进一步处理.
  3. 定期将其发送回Google云端硬盘,以便用户可以将其作为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)

python google-app-engine google-drive-api

6
推荐指数
1
解决办法
5308
查看次数