如何解决来自 laravel 的 Flutter 下载文件:HandshakeException:客户端中的握手错误
我做了一个flutter程序来从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);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。