2022-02-03 09:06:44 -07:00
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
|
|
|
class FileHelper {
|
|
|
|
static getMimeType(String filePath) {
|
|
|
|
var fileExtension = p.extension(filePath).split(".")[1];
|
|
|
|
|
2022-02-05 23:07:56 -07:00
|
|
|
switch (fileExtension.toLowerCase()) {
|
2022-02-03 09:06:44 -07: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"};
|
|
|
|
|
|
|
|
case 'mov':
|
|
|
|
return {"type": "video", "subType": "quicktime"};
|
|
|
|
|
|
|
|
case 'mp4':
|
|
|
|
return {"type": "video", "subType": "mp4"};
|
|
|
|
|
|
|
|
case 'avi':
|
|
|
|
return {"type": "video", "subType": "x-msvideo"};
|
|
|
|
|
2022-02-09 19:48:06 -07:00
|
|
|
case 'heic':
|
|
|
|
return {"type": "image", "subType": "heic"};
|
|
|
|
|
|
|
|
case 'heif':
|
|
|
|
return {"type": "image", "subType": "heif"};
|
|
|
|
|
2022-03-18 18:23:05 -07:00
|
|
|
case 'dng':
|
|
|
|
return {"type": "image", "subType": "dng"};
|
|
|
|
|
2022-04-04 21:37:48 -07:00
|
|
|
case 'webp':
|
|
|
|
return {"type": "image", "subType": "webp"};
|
|
|
|
|
2022-02-03 09:06:44 -07:00
|
|
|
default:
|
|
|
|
return {"type": "unsupport", "subType": "unsupport"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|