2022-02-06 08:07:56 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-02-03 18:06:44 +02:00
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
|
|
|
class FileHelper {
|
|
|
|
static getMimeType(String filePath) {
|
2022-02-06 08:07:56 +02:00
|
|
|
debugPrint(filePath);
|
2022-02-03 18:06:44 +02:00
|
|
|
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"};
|
|
|
|
|
|
|
|
case 'mov':
|
|
|
|
return {"type": "video", "subType": "quicktime"};
|
|
|
|
|
|
|
|
case 'mp4':
|
|
|
|
return {"type": "video", "subType": "mp4"};
|
|
|
|
|
|
|
|
case 'avi':
|
|
|
|
return {"type": "video", "subType": "x-msvideo"};
|
|
|
|
|
|
|
|
default:
|
|
|
|
return {"type": "unsupport", "subType": "unsupport"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|