import { EncodingType , readAsStringAsync } from 'expo-file-system' ; import { Image } from 'react-native' ; import { resolveAsync } from './resolveAsync' ; function getSizeAsync ( uri ) { return new Promise ( ( resolve , reject ) => Image . getSize ( uri , ( width , height ) => resolve ( { width , height } ) , reject ) ) ; } export async function base64forImageUriAsync ( file ) { const asset = await resolveAsync ( file ) ; const size = await getSizeAsync ( asset . localUri ! ) ; const data = await readAsStringAsync ( asset . localUri ! , { encoding : EncodingType . Base64 , } ) ; return { data , size } ; }