2022-02-03 18:06:44 +02:00
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
|
|
|
class FileHelper {
|
|
|
|
static getMimeType(String filePath) {
|
|
|
|
var fileExtension = p.extension(filePath).split(".")[1];
|
|
|
|
|
2022-02-06 08:07:56 +02:00
|
|
|
switch (fileExtension.toLowerCase()) {
|
2022-02-03 18:06:44 +02:00
|
|
|
case 'gif':
|
|
|
|
return {"type": "image", "subType": "gif"};
|
|
|
|
|
|
|
|
case 'jpeg':
|
|
|
|
return {"type": "image", "subType": "jpeg"};
|
|
|
|
|
|
|
|
case 'jpg':
|
|
|
|
return {"type": "image", "subType": "jpeg"};
|
|
|
|
|
|
|
|
case 'png':
|
|
|
|
return {"type": "image", "subType": "png"};
|
|
|
|
|
2022-09-05 15:53:13 +02:00
|
|
|
case 'tif':
|
|
|
|
return {"type": "image", "subType": "tiff"};
|
|
|
|
|
2022-02-03 18:06:44 +02:00
|
|
|
case 'mov':
|
|
|
|
return {"type": "video", "subType": "quicktime"};
|
|
|
|
|
|
|
|
case 'mp4':
|
|
|
|
return {"type": "video", "subType": "mp4"};
|
|
|
|
|
|
|
|
case 'avi':
|
|
|
|
return {"type": "video", "subType": "x-msvideo"};
|
|
|
|
|
2022-02-10 04:48:06 +02:00
|
|
|
case 'heic':
|
|
|
|
return {"type": "image", "subType": "heic"};
|
|
|
|
|
|
|
|
case 'heif':
|
|
|
|
return {"type": "image", "subType": "heif"};
|
|
|
|
|
2022-03-19 03:23:05 +02:00
|
|
|
case 'dng':
|
|
|
|
return {"type": "image", "subType": "dng"};
|
|
|
|
|
2022-04-05 06:37:48 +02:00
|
|
|
case 'webp':
|
|
|
|
return {"type": "image", "subType": "webp"};
|
|
|
|
|
2022-09-05 15:53:13 +02:00
|
|
|
case '3gp':
|
|
|
|
return {"type": "video", "subType": "3gpp"};
|
|
|
|
|
2023-03-27 02:38:23 +02:00
|
|
|
case 'webm':
|
|
|
|
return {"type": "video", "subType": "webm"};
|
|
|
|
|
2023-06-20 04:10:29 +02:00
|
|
|
case 'avif':
|
|
|
|
return {"type": "image", "subType": "avif"};
|
|
|
|
|
2023-06-12 15:29:03 +02:00
|
|
|
case 'insp':
|
|
|
|
return {"type": "image", "subType": "jpeg"};
|
|
|
|
|
|
|
|
case 'insv':
|
|
|
|
return {"type": "video", "subType": "mp4"};
|
|
|
|
|
2023-06-15 04:34:03 +02:00
|
|
|
case 'arw':
|
|
|
|
return {"type": "image", "subType": "x-sony-arw"};
|
|
|
|
|
2023-06-20 04:10:29 +02:00
|
|
|
case 'raf':
|
|
|
|
return {"type": "image", "subType": "x-fuji-raf"};
|
|
|
|
|
|
|
|
case 'nef':
|
|
|
|
return {"type": "image", "subType": "x-nikon-nef"};
|
|
|
|
|
|
|
|
case 'srw':
|
|
|
|
return {"type": "image", "subType": "x-samsung-srw"};
|
|
|
|
|
|
|
|
case 'crw':
|
|
|
|
return {"type": "image", "subType": "x-canon-crw"};
|
|
|
|
|
|
|
|
case 'cr2':
|
|
|
|
return {"type": "image", "subType": "x-canon-cr2"};
|
|
|
|
|
|
|
|
case 'cr3':
|
|
|
|
return {"type": "image", "subType": "x-canon-cr3"};
|
|
|
|
|
|
|
|
case 'erf':
|
|
|
|
return {"type": "image", "subType": "x-epson-erf"};
|
|
|
|
|
|
|
|
case 'dcr':
|
|
|
|
return {"type": "image", "subType": "x-kodak-dcr"};
|
|
|
|
|
|
|
|
case 'k25':
|
|
|
|
return {"type": "image", "subType": "x-kodak-k25"};
|
|
|
|
|
|
|
|
case 'kdc':
|
|
|
|
return {"type": "image", "subType": "x-kodak-kdc"};
|
|
|
|
|
|
|
|
case 'mrw':
|
|
|
|
return {"type": "image", "subType": "x-minolta-mrw"};
|
|
|
|
|
|
|
|
case 'orf':
|
|
|
|
return {"type": "image", "subType": "x-olympus-orf"};
|
|
|
|
|
|
|
|
case 'raw':
|
|
|
|
return {"type": "image", "subType": "x-panasonic-raw"};
|
|
|
|
|
|
|
|
case 'pef':
|
|
|
|
return {"type": "image", "subType": "x-panasonic-pef"};
|
|
|
|
|
|
|
|
case 'x3f':
|
|
|
|
return {"type": "image", "subType": "x-sigma-x3f"};
|
|
|
|
|
|
|
|
case 'srf':
|
|
|
|
return {"type": "image", "subType": "x-sony-srf"};
|
|
|
|
|
|
|
|
case 'sr2':
|
|
|
|
return {"type": "image", "subType": "x-sony-sr2"};
|
|
|
|
|
|
|
|
case '3fr':
|
|
|
|
return {"type": "image", "subType": "x-hasselblad-3fr"};
|
|
|
|
|
|
|
|
case 'fff':
|
|
|
|
return {"type": "image", "subType": "x-hasselblad-fff"};
|
|
|
|
|
|
|
|
case 'rwl':
|
|
|
|
return {"type": "image", "subType": "x-leica-rwl"};
|
|
|
|
|
|
|
|
case 'ori':
|
|
|
|
return {"type": "image", "subType": "x-olympus-ori"};
|
|
|
|
|
|
|
|
case 'iiq':
|
|
|
|
return {"type": "image", "subType": "x-phaseone-iiq"};
|
|
|
|
|
|
|
|
case 'ari':
|
|
|
|
return {"type": "image", "subType": "x-arriflex-ari"};
|
|
|
|
|
|
|
|
case 'cap':
|
|
|
|
return {"type": "image", "subType": "x-phaseone-cap"};
|
|
|
|
|
|
|
|
case 'cin':
|
|
|
|
return {"type": "image", "subType": "x-phantom-cin"};
|
|
|
|
|
2023-06-21 14:29:02 +02:00
|
|
|
case 'jxl':
|
|
|
|
return {"type": "image", "subType": "jxl"};
|
|
|
|
|
2022-02-03 18:06:44 +02:00
|
|
|
default:
|
|
|
|
return {"type": "unsupport", "subType": "unsupport"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|