本文介绍了如何解决OS错误:权限被拒绝,errno = 13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Flutter的新手.我想将文档文件存储到'/storage/emulated/0/Download/'中.我有关于Unhandled Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/file.pdf' (OS Error: Permission denied, errno = 13)
I am new in Flutter. I want to store my document file into '/storage/emulated/0/Download/'. I have error about Unhandled Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/file.pdf' (OS Error: Permission denied, errno = 13)
这是我的代码:
void download() async {
http.Response response = await http.post(url, headers: {"Accept": "application/json", HttpHeaders.authorizationHeader: 'Bearer}});
File file = new File('/storage/emulated/0/Download/file.pdf');
await file.writeAsBytes(response.bodyBytes);
}
推荐答案
确保像这样在AndroidManifest file
中定义权限:
Make sure you defined permissions in AndroidManifest file
like this :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.yyy">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
...
</manifest>
更多信息,请尝试此链接
这篇关于如何解决OS错误:权限被拒绝,errno = 13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!