Get image size in bytes

#1

I want to validate the image size to 2MB before upload. I tried to use FileSystem.getInfoAsync with the ImagePicker result.uri, but it doesn’t find the file…
Any solutions?

#2

Hi! Per the ImagePicker docs:

The local image URI is temporary. Use Expo.FileSystem.copyAsync to make a permanent copy of the image.

Are you attempting to do this immediately after the image is returned, or are you saving the URI for later?

#3

Hi there, im doing this immediatelly after the img is returned. I tried to make a copy with Expo.FileSystem.copyAsync, but it gives me a error saying that is undefined.
Strange, because, of the Expo.FileSystem, i can use only getInfoAsync(), all the other functions are ‘undefined’

#4

What SDK version are you using?

#5

version 15.0.0, but im trying to upgrade it to the last version, can it be the problem?

#6

I’m not sure the FileSystem APIs you’re looking for are available on SDK 15. Can you try on a newer SDK?

#7

I updated to the version 20.0.0 following the steps on the blog, but now its giving me the message:
undefined is not an object (evaluating ‘ReactInternals.ReactCurrentOwner’)

#8

trying to update now all the versions of react-native, react, and expo, i forgot to update react and react-native before…

#9

Updated to version 20.0.0, some warnings, but now it seems to run with no problems