下载管理器使用 rn-fetch-blob 给出错误代码 16
下载管理器使用 rn-fetch-blob 给出错误代码 16。如果我使用 Android 下载管理器。如果不这样做,请使用 Android 下载管理器,然后应用程序就会崩溃。
android版本:11。
代码:
let dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
addAndroidDownloads : {
useDownloadManager : true,
notification : true,
mime : 'image/*',
mediaScannable : true,
description : 'File downloaded by download manager.',
path : dirs.DownloadDir + '/' + fileName,
overwrite: true,
fileCache: true,
},
})
.fetch('GET', FILE_URL, {
Authorization: `Bearer ${token}`,
})
.then((res) => {
console.log('The file saved to ', res.path())
})
在manifest.xml中设置以下:
<application android:requestLegacyExternalStorage="true" ... />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
如果有人可以为我提供解决方案,请。
download manager gives error code 16 with rn-fetch-blob. If I use the android download manager. If I don't, use the android download manager, then the app crashes.
android version: 11.
Code:
let dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
addAndroidDownloads : {
useDownloadManager : true,
notification : true,
mime : 'image/*',
mediaScannable : true,
description : 'File downloaded by download manager.',
path : dirs.DownloadDir + '/' + fileName,
overwrite: true,
fileCache: true,
},
})
.fetch('GET', FILE_URL, {
Authorization: `Bearer ${token}`,
})
.then((res) => {
console.log('The file saved to ', res.path())
})
Following are set in manifest.xml:
<application android:requestLegacyExternalStorage="true" ... />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
Please if anyone can provide me with a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据他们的 自述,您需要在使用下载管理器时添加 DOWNLOAD_COMPLETE 操作。
另外,当需要的调用缺少身份验证标头时,我遇到了错误代码 16。
According to their readme, you need to add the DOWNLOAD_COMPLETE action when using the download manager.
Also, I've been facing the error code 16 when the Authentication header was missing for a call that needed one.