【发布时间】:2018-08-02 21:38:52
【问题描述】:
我是 Flutter 的新手,正在尝试接收从后端发送的 PDF
我有一个 python 烧瓶后端,它使用 send_file 使用 get 请求发送 pdf:
return send_file(os.getcwd() + '/output.pdf', attachment_filename='output.pdf')
我正在尝试使用以下方法在颤振中检索它:
File file = new File(_localPath + "output.pdf");
try{
await http
.get(PDF_URL + "?property_id=153",
headers : {"Content-Type" : "application/json"})
.then((response) async {
await file.writeAsBytes(response.bodyBytes);
});
} catch (Exception) {
print(Exception.toString());
}
我不知道如何从响应中检索 PDF,因为我有一个使用相同后端的 react Web 应用程序,它使用以下方法成功打开了 PDF:
window.location.assign(response.url, '_blank')
【问题讨论】: