'React-native <Image> onProgress event returning wrong event.nativeEvent.total in Android

I am using onProgress event of Image component from react-native to try to get the file size in bytes of the remote image (the source uses uri).

In iOS everything works great, however in Android sometimes is undefined and other times it just return a random value like 10000.

Do you know any solution for this? I would like to keep using only Image from react-native, ie, I want to avoid to have to install a third party library or re-fetching the server.

const handleOnProgress = (event: OnProgressEvent) => {
    const filesize = event.nativeEvent.total; // does not work in Android
}

   <Image
        ...
        onProgress={handleOnProgress}
      />


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source