react-native在资产中找不到文件夹,但在文件夹中找到文件

时间:2019-02-26 21:12:44

标签: javascript android react-native

  • 版本:RN(0.57.7)rn-fetch-blob(0.10.13)

我需要将文件夹从资产复制到文档

此代码适用于ios

const preInstallPath = `${RNFB.fs.dirs.MainBundleDir}/preinstalled-ads`;
const adsPath =`${RNFB.fs.dirs.DocumentDir}/ads`;
try{
        await RNFB.fs.cp(preInstallPath,adsPath);
        console.log('Copy pre ads finished ok');
        return true;
      }catch (e) {
        console.log('Problem with copy pre ads: ',e);
        return false;
}

我的问题是Android 当我尝试从资产中获取文件夹时,出现错误 例子

when I do this 
await RNFB.fs.stat(RNFB.fs.asset('preinstalled-ads/5iy2xw/assets/gyN7hS4C.jpeg'));
i get file status 

but when I try this 
await RNFB.fs.stat(RNFB.fs.asset('preinstalled-ads/'));

I get error 
Possible Unhandled Promise Rejection (id: 0):
Error: failed to stat path `bundle-assets://preinstalled-ads/` because it does not exist or it is not a folder

谁可以让该文件夹工作?

0 个答案:

没有答案