簡體   English   中英

上傳文件Google App - Python

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM