According to the doc, the current prefetch method doesn't consider headers as same as . Does anyone know wether this is going to be fixed when the API is completed?
For the logic of our custom image caching component, we'll import expo-file-system : import * as FileSystem from "expo-file-system"; First, we need to create a new local path for our remote image using the cacheKey (unique ID) to check whether it already exists in the local cache and, if not, download it.
Hope it's not too late, I faced this issue before, and currently the prefetch method still not take any headers.
I found out there's a method in Image class named getSizeWithHeaders, base on the description:
In order to retrieve the image dimensions, the image may first need to be loaded or downloaded, after which it will be cached. This means that in principle you could use this method to preload images
So if you use this method, it did prefetch the Image with headers for you, which fulfill your requirement even it's not optimized.
Looks like this is the only method to solve this, please correct me if there's any optimized method or library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With