2016-05-30 102 views

回答

1

尝试RNFS,它可以正确地下载文件到本地目录中,做到这一点,但我有问题,与显示此图像OMG

RNFS.downloadFile({ 
    fromUrl: string;   // URL to download file from 
    toFile: string;   // Local filesystem path to save the file to 
    headers?: Headers;  // An object of headers to be passed to the server 
    background?: boolean; 
    progressDivider?: number; 
    begin?: (res: DownloadBeginCallbackResult) => void; 
    progress?: (res: DownloadProgressCallbackResult) => void; 
} 

你可以检查文件是否是已下载:

RNFS.exists(ICON).then(function(file){ 
    if(!file){ 
     RNFS.downloadFile({ 
     fromUrl: 'string', 
     toFile : 'string' 
    }).catch(function(e){console.log(e)}) 
    } 
}).catch(function(e){console.log(e)}) 
相关问题