[英]Uploading a file Google App - Python
希望有人可以帮助治愈我的愚蠢。 我正在创建一个webapp,我需要上传csv文件并进行处理。 我正在努力让我的代码以最简单的形式工作。 我可以加载页面,但是当我按下提交按钮发布文件时,我得到403 Forbidden Error: Access was denied to this resource
。
当我在谷歌应用程序交互式控制台中运行它时,它不会给我任何错误。 有人可以指出我正确的方向。
HTML:
{% extends base_layout %}
{% block header_title %}
{% trans %}Upload Documents{% endtrans %}
{% endblock %}
{% block content %}
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="myfile">
<br>
<input type="submit" name="submit" value="Submit">
{% endblock %}
处理程序类:
class Upload(BaseHandler):
def get(self):
return self.render_template('upload.html')
def post(self):
file = self.request.POST.getall('myfile')
#file will be process with data going into models here.
self.response.out.write("success")
您不能简单地将文件上传到应用引擎,因为文件系统是只读的。 您必须上传到云存储或blob存储。 使用时,您必须使用每个设施。
通过表单上传文件的最简单快捷的方法是使用blobstore api 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.