Handling of mimetypes on web with a map
This commit is contained in:
@@ -60,6 +60,18 @@ export const fileUploadHandler = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getMimeType(file: File) {
|
||||||
|
const extension = file.name.split('.').pop() as string;
|
||||||
|
switch (extension) {
|
||||||
|
case 'raf':
|
||||||
|
return 'image/x-fuji-raf';
|
||||||
|
case 'srw':
|
||||||
|
return 'image/x-samsung-srw';
|
||||||
|
default:
|
||||||
|
return file.type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: should probably use the @api SDK
|
//TODO: should probably use the @api SDK
|
||||||
async function fileUploader(
|
async function fileUploader(
|
||||||
asset: File,
|
asset: File,
|
||||||
@@ -67,7 +79,8 @@ async function fileUploader(
|
|||||||
sharedKey: string | undefined = undefined,
|
sharedKey: string | undefined = undefined,
|
||||||
onDone?: (id: string) => void
|
onDone?: (id: string) => void
|
||||||
) {
|
) {
|
||||||
const assetType = asset.type.split('/')[0].toUpperCase();
|
const mimeType = getMimeType(asset);
|
||||||
|
const assetType = mimeType.split('/')[0].toUpperCase();
|
||||||
const temp = asset.name.split('.');
|
const temp = asset.name.split('.');
|
||||||
const fileExtension = temp[temp.length - 1];
|
const fileExtension = temp[temp.length - 1];
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|||||||
Reference in New Issue
Block a user