使用rn-fetch-blob react native从Firebase存储下载视频

时间:2020-09-14 08:00:25

标签: react-native rn-fetch-blob

我正在尝试rn-fetch-blob,我想从Firebase下载mp4文件。我的功能在iOS上运行良好,只有在android上才能下载3个视频。只有他只显示1。我认为它正在覆盖路径,但是我不知道如何更改它。有人可以帮我吗?

这是用于下载的mij函数:

downloadVideo(post){
      console.log("Video"+post.image);
      let fullPost = post;
      let dirs =RNFetchBlob.fs.dirs;

      RNFetchBlob
      .config({
        fileCache : false,
        appendExt: 'mp4',
        addAndroidDownloads : {
          useDownloadManager : true, // <-- this is the only thing required
          // Optional, override notification setting (default to true)
          notification : true,
          // Optional, but recommended since android DownloadManager will fail when
          // the url does not contains a file extension, by default the mime type will be text/plain
          mime : 'mp4',
          description : 'File downloaded by download manager.',
          path: RNFetchBlob.fs.dirs.DownloadDir+"/filename.ext"
      }
        
      })
      .fetch('GET', fullPost.image, {
        //some headers ..
      })
      .then((res) => {
        // the temp file path
        //console.log('The file saved to ', res.path())
        
        let path =res.path();
        console.log("het padje:"+path)

          var newelement = {date: fullPost.date, function: fullPost.function,image: path,name: fullPost.name, text: fullPost.text, type:fullPost.type,post: fullPost.post};
          this.setState(prevState => ({
            messages: [...prevState.messages, newelement]
          }))
      })

    }

messages数组是我在视图中映射的het数组。

0 个答案:

没有答案