UBERF-8530 Fix empty image/video upload (#7030)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-10-24 17:29:11 +07:00 committed by GitHub
parent 7eec2b55eb
commit 2390b0d761
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -13,6 +13,7 @@
// limitations under the License.
//
import { Analytics } from '@hcengineering/analytics'
import { type Blob, type Ref } from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import { type PopupAlignment } from '@hcengineering/ui'
@ -36,7 +37,13 @@ export async function getFileMetadata (file: FileOrBlob, uuid: Ref<Blob>): Promi
return undefined
}
return await metadataProvider(file, uuid)
try {
return await metadataProvider(file, uuid)
} catch (err) {
console.error(err)
Analytics.handleError(err as Error)
return undefined
}
}
/**

View File

@ -17,6 +17,10 @@ import { type Blob, type Ref } from '@hcengineering/core'
import { type BlobMetadata, getImageSize } from '@hcengineering/presentation'
export async function blobImageMetadata (file: File, blob: Ref<Blob>): Promise<BlobMetadata | undefined> {
if (file.size === 0) {
return undefined
}
const size = await getImageSize(file)
return {
@ -27,6 +31,10 @@ export async function blobImageMetadata (file: File, blob: Ref<Blob>): Promise<B
}
export async function blobVideoMetadata (file: File, blob: Ref<Blob>): Promise<BlobMetadata | undefined> {
if (file.size === 0) {
return undefined
}
const size = await getVideoSize(file)
if (size === undefined) {