react-native - React Native:下载后无法找到音频文件
问题描述
我正在使用 react-native-simple-download-manager 将音频文件下载到应用程序的下载文件夹中:
headers = {
Authorization: "Téléchargement"
};
config = {
downloadTitle: `${audio.Title}`,
downloadDescription: "Téléchargement",
saveAsName: audio.Title +'.mp3',
allowedInRoaming: true,
allowedInMetered: true,
showInDownloads: true,
external: false, //when false basically means use the default Download path (version ^1.3)
};
downloadManager
.download((url = audio.FileUrl), (headers = headers), (config = config))
.then(response => {
saveData(audio);
})
.catch(err => {
if(index > -1) {
global.downloadingSongId.splice(index,1);
}
});
我可以在手机上找到下载的音频文件,但是播放器无法读取以下路径给出的音频:dirs.DocumentDir + '/Download/' + audio.Title + '.mp3'
当我使用 RNFetchBlob 检查路径是否存在时,它总是返回 false :
let path = dirs.DocumentDir + '/' + audio.Title + '.mp3';
RNFetchBlob.fs.exists(path);
如果有人能提供帮助,我真的很感激!
解决方案
推荐阅读
- javascript - React.js 在 props 上使用 array.prototype.map 返回空数组
- pytorch - 拥抱脸 - RuntimeError:在 Azure Databricks 上的设备 0 上的副本 0 中捕获 RuntimeError
- swagger - Swagger 发送和接收数组
- java - 在链表操作中使用哨兵节点
- windows - 是否允许将路径作为 URL 传递给 Media Foundation?
- reactjs - 错误:元素类型无效,检查渲染方法
- c# - .NET Core 3.1 - HostingEnvironment 不包含 MapPath 的定义
- c++ - C++:如何使用大 int/double 克服内存问题?
- c# - 获取 Azure Key Valut 机密,返回 null/Not Found/Ojbect 未设置
- html - Safari 手机屏幕上的文本渲染问题