[IOS] FileSystem.getInfoAsync giving wrong file size.

Hello,
I’m getting wrong values from FileSystem.getInfoAsync on IOS. For example, the following:

FileSystem.getInfoAsync(image.uri, { md5: false, size: true })

Returns a size of 811895, and then, when I upload the image to S3, it ends up as a 3mb file. I have no problems with android though, I get a filesize of ~100000 for a file that weights 100kb

Any idea about why this could be happening? Or anyone knows an alternative to FileSystem that does not require ejecting from Expo?

Thanks!
Gabriel.

Hey @gaboleskul,

Could you share a snack showing a complete code sample? Just so I can rule anything else out

Thanks!

Hey @charliecruzan,
I met the same problem, the steps to reproduce are as follows.

  1. get file info, current file’s size is 100k
var file = await FileSystem.getInfoAsync(uri, { md5: true, size: true });
  1. compress file, current expo api show size is 40k
var file = await ImageManipulator.manipulateAsync(uri, [{ resize: { width: 300, height: 300} }], { compress: 0.48 })
  1. get file info, current expo api show size is 40k
var file = await FileSystem.getInfoAsync(uri, { md5: true, size: true });
  1. upload file, current actual file size is 300k from the progress info.
var formData = new FormData(); 
        var fileObj: any = {
            uri: "file:///localpath",
            name: "file",
            type: "image/jpeg"
        }
        formData.append('file', fileObj);
        await axios.post("<upload url>", formData, {
            headers: {
                Authorization
            },
            onUploadProgress(res) {
                if (res.lengthComputable) {
                    onProgress && onProgress({
                        loaded: res.loaded,
                        total: res.total,
                        progress: (res.loaded / res.total)
                    })
                }
            }
        });

I’m ensure using the right file path, but the file is bigger than call expo api gets(FileSystem.getInfoAsync)

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.