我在 GAE/Python 上使用 Flask Web 框架。将文件上传到 Cloud Storage 后,我想获得对该文件的引用,以便提供该文件。我无法让 parse_file_info 工作。我已经进行了漫长而艰苦的搜索,并花了两天多的时间试图完成这项工作。我已经无计可施了!!你可以在下面看到我的处理程序:
@app.route('/upload_form', methods = ['GET'])
def upload_form():
blobupload_url = blobstore.create_upload_url('/upload', gs_bucket_name = 'mystorage')
return render_template('upload_form.html', blobupload_url = blobupload_url)
@app.route('/upload', methods = ['POST'])
def blobupload():
file_info = blobstore.parse_file_info(cgi.FieldStorage()['file'])
return file_info.gs_object_name