【发布时间】:2020-02-25 18:43:17
【问题描述】:
是否可以生成文件并将其上传到 s3?
我试图实现这个烧瓶应用程序,但它因以下错误而死:
OSError: [Errno 30] Read-only file system: '/report.csv'
这是我的 app.py:
@app.route("/upload/<string:START_REPORT>/<string:STOP_REPORT>/<string:IDS>/", methods=['POST'])
def upload(START_REPORT, STOP_REPORT, IDS):
"""
Function to upload a file to an S3 bucket
"""
os.environ["START_REPORT"] = START_REPORT
os.environ["STOP_REPORT"] = STOP_REPORT
os.environ["IDS"] = IDS
dft, filename = report_visit.report()
dft.to_csv(filename, index=False) # <-- Error here
object_name = filename
s3_client = boto3.client(
"s3",
region_name='eu-west-1',
endpoint_url="url",
aws_access_key_id="key",
aws_secret_access_key="key"
)
with open(filename, "rb") as f:
response = s3_client.upload_fileobj(f, app.config['UPLOAD_FOLDER'], f.filename)
return response
if __name__ == '__main__':
app.run (debug=True, port='8080', host='127.0.0.1')
其中文件名是“report.csv”
这是我对邮递员的发帖请求:
POST http://localhost:8080/upload/2020_2_10_0_0_0_0/2020_2_10_1_0_0_0/138/
我认为我很难给出一个合适的工作示例,但欢迎提出任何建议
函数report_visit.report()返回一个pandas数据框和文件名
任何建议都将不胜感激,谢谢
马特奥
【问题讨论】: