我正在使用 AWS 和 python + bottle 来下载文件。
以下代码运行良好,文件下载时没有本地系统中的任何问题。
from bottle import route, run, template, response, HTTPResponse,static_file
@route('/static/<file_path:path>')
def static(file_path):
return static_file(file_path, root='./static', mimetype='application/octet-stream',
download='exam.bin', charset='UTF-8')
run(host='localhost', port=8080)
但是在 AWS 中,以下代码无效
from bottle import route, run, template, response, HTTPResponse,static_file
def lambda_handler(event, context):
return static_file(file_path,
root='./static',
mimetype='application/octet-stream',
download='exam.bin',
charset='UTF-8')
提供以下错误:
{ &#34; errorMessage&#34;:&#34; Content-Type:application / octet-stream \ nContent-Disposition:attachment; filename = \&#34; exam.bin \&#34; \ nContent-Length:632 \ nLast-Modified:Thu,01 Jun 2017 15:13:58 GMT \ nAccept-Ranges:bytes \ n不是JSON可序列化的&# 34 ;, &#34; errorType&#34;:&#34; TypeError&#34; }
请帮助解决这个问题,..