attachment-file.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // 附件处理——格式
  2. const judgeFileFormat = (fileType) => {
  3. console.log(fileType, 'fileType');
  4. let fileFormat = '';
  5. switch (fileType) {
  6. case 'txt':
  7. return fileFormat = 'text/plain';
  8. case 'docx':
  9. // return fileFormat = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
  10. return fileFormat = 'application/msword';
  11. // return fileFormat = 'application/x-msdownload';
  12. case 'doc':
  13. return fileFormat = 'application/msword';
  14. case 'xlsx':
  15. return fileFormat = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  16. case 'xls':
  17. return fileFormat = 'application/vnd.ms-excel';
  18. case 'pptx':
  19. return fileFormat = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
  20. case 'ppt':
  21. return fileFormat = 'application/vnd.ms-powerpoint';
  22. case 'pdf':
  23. return fileFormat = 'application/pdf';
  24. case 'zip':
  25. return fileFormat = 'application/zip';
  26. case 'rar':
  27. return fileFormat = 'application/x-rar-compressed';
  28. case 'jpg':
  29. return fileFormat = 'image/jpeg';
  30. case 'jpeg':
  31. return fileFormat = 'image/jpeg';
  32. case 'png':
  33. return fileFormat = 'image/png';
  34. case 'gif':
  35. return fileFormat = 'image/gif';
  36. case 'bmp':
  37. return fileFormat = 'image/bmp';
  38. case 'mp3':
  39. return fileFormat = 'audio/mpeg';
  40. case 'mp4':
  41. return fileFormat = 'video/mp4';
  42. case 'avi':
  43. return fileFormat = 'video/x-msvideo';
  44. }
  45. }
  46. export default judgeFileFormat;