エラーハンドリング

This commit is contained in:
tamaina 2022-02-07 03:26:22 +09:00
parent fdb17e08b9
commit 7102e43e1e

View file

@ -62,9 +62,13 @@ export function uploadFile(
...(changeType ? {} : { mimeType: file.type }), ...(changeType ? {} : { mimeType: file.type }),
}; };
const { readAndCompressImage } = await import('browser-image-resizer'); try {
resizedImage = await readAndCompressImage(file, config); const { readAndCompressImage } = await import('browser-image-resizer');
ctx.name = changeType ? `${ctx.name}.${mimeTypeMap[compressTypeMap[file.type].mimeType]}` : ctx.name; resizedImage = await readAndCompressImage(file, config);
ctx.name = changeType ? `${ctx.name}.${mimeTypeMap[compressTypeMap[file.type].mimeType]}` : ctx.name;
} catch (e) {
console.error('Failed to resize image', e);
}
} }
const data = new FormData(); const data = new FormData();