使用Flask(在App Engine上运行)将文件上传到Google云端硬盘 [英] Uploading files with Flask (running on App Engine) to Google Drive

查看:117
本文介绍了使用Flask(在App Engine上运行)将文件上传到Google云端硬盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用在App Engine上运行的Flask将文件上传到Google云端硬盘.我启动并运行了Google云端硬盘服务(由Google云端硬盘API构建),并能够使用files().insert(...)从服务器上传文件.

I would like to upload a file to Google Drive using Flask which runs on App Engine. I got Google Drive service (constructed with Google Drive API) up and running and was able to upload a file from the server using files().insert(...).

现在,我想通过HTML表单实现上传.这给了我一个 FileStorage 对象.从这一点开始,我应该如何进行操作才能在Google云端硬盘中获取文件?

Now I would like to implement uploading via HTML form. This gives me a FileStorage object. How should I proceed from this point in order to get the file inside Google Drive?

请注意,我上传的文件超出了App Engine的5MB的请求大小限制.

Please note that I'm uploading files that exceed App Engine's 5MB limit on request size.

谢谢您的建议.

推荐答案

使用回调将表单上载到blobstore到您的前端. 如果文件很大,您可能需要走到后端,并在链式后端上进行可恢复的上载(因为对于大型文件,后端也可能会在上载过程中掉线)

Upload the form to blobstore with a callback into your frontend. If the file is very large you might need to go as far as a backend with resumable uploads done on chained backends (as backends could also go down in the middle of the upload for huge files)

这篇关于使用Flask(在App Engine上运行)将文件上传到Google云端硬盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆