APP-2971: Fix onboarding avatar compression after Expo 57 (#11580)
(cherry picked from commit 9d76e42606)
This commit is contained in:
committed by
Eric Bailey
parent
f0e04f448e
commit
1d809571fc
@@ -0,0 +1,9 @@
|
||||
import {getInfoAsync} from 'expo-file-system/legacy'
|
||||
|
||||
export async function getUriSize(uri: string): Promise<number> {
|
||||
const info = await getInfoAsync(uri)
|
||||
if (!info.exists) {
|
||||
throw new Error('Failed to read image size')
|
||||
}
|
||||
return info.size
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export async function getUriSize(uri: string): Promise<number> {
|
||||
const response = await fetch(uri)
|
||||
const blob = await response.blob()
|
||||
return blob.size
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
|
||||
import {usePhotoLibraryPermission} from '#/lib/hooks/usePermissions'
|
||||
import {compressIfNeeded} from '#/lib/media/manip'
|
||||
import {openCropper} from '#/lib/media/picker'
|
||||
import {getDataUriSize} from '#/lib/media/util'
|
||||
import {getUriSize} from '#/lib/media/uriSize'
|
||||
import {useRequestNotificationsPermission} from '#/lib/notifications/notifications'
|
||||
import {isCancelledError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
@@ -133,7 +133,7 @@ export function StepProfile() {
|
||||
height: rendered.height,
|
||||
width: rendered.width,
|
||||
path: result.uri,
|
||||
size: getDataUriSize(result.uri),
|
||||
size: await getUriSize(result.uri),
|
||||
},
|
||||
]
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user