Merge pull request #3201 from bluesky-social/samuel/handle-invalid-files

Filter out non-image files from image picker
zio/stable
Samuel Newman 2024-03-13 17:59:03 +00:00 committed by GitHub
commit 44b3a37f65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 7 deletions

View File

@ -18,7 +18,14 @@ export async function openPicker(opts?: ImagePickerOptions) {
Toast.show('You may only select up to 4 images') Toast.show('You may only select up to 4 images')
} }
return (response.assets ?? []).slice(0, 4).map(image => ({ return (response.assets ?? [])
.slice(0, 4)
.filter(asset => {
if (asset.mimeType?.startsWith('image/')) return true
Toast.show('Only image files are supported')
return false
})
.map(image => ({
mime: 'image/jpeg', mime: 'image/jpeg',
height: image.height, height: image.height,
width: image.width, width: image.width,