fix: properly detect the mime type being passed

This commit is contained in:
Mary
2024-05-07 22:41:11 +07:00
parent a0da3a2a45
commit d2f7578769
2 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -3,8 +3,9 @@ import {
launchImageLibraryAsync,
MediaTypeOptions,
} from 'expo-image-picker'
import {getDataUriSize} from './util'
import * as Toast from 'view/com/util/Toast'
import {getDataUriSize} from './util'
export async function openPicker(opts?: ImagePickerOptions) {
const response = await launchImageLibraryAsync({
@@ -26,7 +27,7 @@ export async function openPicker(opts?: ImagePickerOptions) {
return false
})
.map(image => ({
mime: 'image/jpeg',
mime: image.mimeType || 'image/jpeg',
height: image.height,
width: image.width,
path: image.uri,
+2 -1
View File
@@ -91,6 +91,7 @@ export async function pasteImage(
uri: string,
): Promise<ComposerImageWithoutTransformation> {
const {width, height} = await getImageDim(uri)
const match = /^data:(.+?);/.exec(uri)
return {
alt: '',
@@ -98,7 +99,7 @@ export async function pasteImage(
path: uri,
width: width,
height: height,
mime: 'image/jpeg',
mime: match ? match[1] : 'image/jpeg',
},
}
}