files_helper.dart 870 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'package:flutter/material.dart';
  2. import 'package:path/path.dart' as p;
  3. class FileHelper {
  4. static getMimeType(String filePath) {
  5. debugPrint(filePath);
  6. var fileExtension = p.extension(filePath).split(".")[1];
  7. switch (fileExtension.toLowerCase()) {
  8. case 'gif':
  9. return {"type": "image", "subType": "gif"};
  10. case 'jpeg':
  11. return {"type": "image", "subType": "jpeg"};
  12. case 'jpg':
  13. return {"type": "image", "subType": "jpeg"};
  14. case 'png':
  15. return {"type": "image", "subType": "png"};
  16. case 'mov':
  17. return {"type": "video", "subType": "quicktime"};
  18. case 'mp4':
  19. return {"type": "video", "subType": "mp4"};
  20. case 'avi':
  21. return {"type": "video", "subType": "x-msvideo"};
  22. default:
  23. return {"type": "unsupport", "subType": "unsupport"};
  24. }
  25. }
  26. }