2014-10-20 132 views
0

我正在使用Flask/Heroku和Boto库。我要上传的文件保存在我的S3 ...无法使用Boto将文件上传到Amazon S3

@app.route("/step3/", methods = ["GET", "POST"]) 
def step3(): 
    if request.method == "GET": 
     return render_template("step3.html") 
    else: 
     file = request.files['resume'] 
     if file and allowed_file(file.filename): 
      filename = secure_filename(file.filename) 
      k = Key(S3_BUCKET) 
      k.key = "TEST" 
      k.set_contents_from_filename(file) 
      return redirect(url_for("preview")) 

但下面给我下面......

TypeError: coercing to Unicode: need string or buffer, FileStorage found 

回答

1

为了写它,你需要改变你的文件作为一个字符串这意味着你需要在打开它后阅读它。

相关问题