2016-05-30 99 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)}) 
相關問題