Rn-fetch-blob: [Help Wanted] How to get a file from android assets folder to the document directory

Created on 22 Oct 2018  路  1Comment  路  Source: joltup/rn-fetch-blob

Hi I have file that I want to copy/move from the android assets folder to the document directory folder. How can I achieve this? TIA :)

Most helpful comment

Got it working..

let myAsset= RNFetchBlob.fs.asset('myFile.jpg');
const targetPath = dirs.DocumentDir;

RNFetchBlob.fs.exists(dirs.DocumentDir + "/myFile.jpg'")
 .then((exist) => {
  if(!exist) {
   RNFetchBlob.fs.cp(myAsset, targetPath)
    .then(() => {
           console.log("copied")
        })
 }
})

>All comments

Got it working..

let myAsset= RNFetchBlob.fs.asset('myFile.jpg');
const targetPath = dirs.DocumentDir;

RNFetchBlob.fs.exists(dirs.DocumentDir + "/myFile.jpg'")
 .then((exist) => {
  if(!exist) {
   RNFetchBlob.fs.cp(myAsset, targetPath)
    .then(() => {
           console.log("copied")
        })
 }
})

Was this page helpful?
0 / 5 - 0 ratings