1
它似乎像提取沒有在圖像下載工作。如何下載圖像並將其保存到本地應用程序中的反應本地應用程序
fetch("url to image").then((resp) => {
return resp.blob();
})
它似乎像提取沒有在圖像下載工作。如何下載圖像並將其保存到本地應用程序中的反應本地應用程序
fetch("url to image").then((resp) => {
return resp.blob();
})
嘗試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)})
我可以知道爲什麼你想將圖像保存在localStorage中? – Jickson
我想緩存它。而不是每次啓動應用時都要求提供。 –