laravel - 从 laravel 下载 Flutter 文件:HandshakeException: Handshake error in client
问题描述
我制作了一个颤振程序来从 laravel 下载 pdf 文件。按下载按钮时出现错误。
Exception has occurred.
HandshakeException (HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354)))
这是我的下载功能:
Future<File> _downloadFile() async{
final res = await Network().download("/letter/download/${surat.id_surat}");
var bytes = await consolidateHttpClientResponseBytes(res);
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/Surat_${surat.id_surat}');
await file.writeAsBytes(bytes);
return file;
}
这就是 Network() 的功能
download(apiUrl) async{
var fullUrl = "https://sub.domain.id/api" + apiUrl;
await _getToken();
return await http.get(
fullUrl,
headers: _setHeaders()
);
}
这是我的 Laravel 下载 pdf 文件的功能
public function download($id_surat){
$fileName = $this->saveToPDF($id_surat);
$file = public_path()."/surat/".$fileName;
$headers = array('Content-Type: application/pdf',);
return Response::download($file, $fileName, $headers);
}
解决方案
推荐阅读
- apache-camel - 如何在骆驼单义性固定解析器中允许更短的行?
- php - 如何配置 symfony 来记录弃用?
- python - 将字典列表导出到excel
- sql - 当 In 和 Out 时间在同一列时计算时间差
- mainframe - 在连接的 DD 语句中包含 ZFS 失败并出现异常终止 S112 和消息 IEC908I 112-04
- twig - 如何在 twig drupal 8 中循环段落列表(实体参考修订列表)
- node.js - 无法使用 nodejs 设置与浏览器的 socket.io 连接
- hibernate - 无法插入数据库
- three.js - Three.js r111 THREE.ShaderLib.cube 统一 tCube 到 envMap 问题
- python - 如何比较python中的两个列表并在一个列表中写入相似的索引值,在另一个列表中写入不相似的值