0
私はダウンロードイメージにreact-native-fetch-blobを使用しています。イメージのダウンロード速度を改善するにはどうすればよいですか?
私のソースコードです。
downloadThumb(element) {
return new Promise((resolve, reject) => {
RNFetchBlob.config({
// add this option that makes response data to be stored as a file,
// this is much more performant.
fileCache: true,
path: `${DocumentDirectoryPath}/thumbs/${element}`,
})
.fetch(
'GET',
`https://www.searchforsites.co.uk/images/thumbs/${element}`,
{
// some headers ..
},
)
.then((res) => {
resolve(true);
})
.catch((err) => {
// console.log('Error: ', err);
// this.setState({ modalOpen: false, regionUpdated: true });
// this.findUser();
reject(true);
});
});
}
///////////////////////////////////////
recursive_thumb(element) {
this.downloadThumb(element).then((response) => {
if (this.state.count > this.state.total_thumbs) {
this.setState({ modalOpen: false });
setThumbDownloaded();
return true;
}
this.state.count += 1;
// console.log(this.state.count);
this.setState({ totalCount: this.state.total_thumbs, fetchedCount: this.state.count });
this.recursive_thumb(this.state.thumbs[this.state.count]);
});
}
ファイルサイズは約8KBです。今私はひとつずつドローロードしています。 1枚の画像(8KB)をダウンロードするのに1秒かかります。
ダウンロード速度を改善するソリューションはありますか?
お時間をいただきありがとうございます。