No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

57 líneas
2.0 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.COMMON_MIME_TYPES = new Map([
  4. ['avi', 'video/avi'],
  5. ['gif', 'image/gif'],
  6. ['ico', 'image/x-icon'],
  7. ['jpeg', 'image/jpeg'],
  8. ['jpg', 'image/jpeg'],
  9. ['mkv', 'video/x-matroska'],
  10. ['mov', 'video/quicktime'],
  11. ['mp4', 'video/mp4'],
  12. ['pdf', 'application/pdf'],
  13. ['png', 'image/png'],
  14. ['zip', 'application/zip'],
  15. ['doc', 'application/msword'],
  16. ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
  17. ]);
  18. function toFileWithPath(file, path) {
  19. var f = withMimeType(file);
  20. if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path
  21. var webkitRelativePath = file.webkitRelativePath;
  22. Object.defineProperty(f, 'path', {
  23. value: typeof path === 'string'
  24. ? path
  25. // If <input webkitdirectory> is set,
  26. // the File will have a {webkitRelativePath} property
  27. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
  28. : typeof webkitRelativePath === 'string' && webkitRelativePath.length > 0
  29. ? webkitRelativePath
  30. : file.name,
  31. writable: false,
  32. configurable: false,
  33. enumerable: true
  34. });
  35. }
  36. return f;
  37. }
  38. exports.toFileWithPath = toFileWithPath;
  39. function withMimeType(file) {
  40. var name = file.name;
  41. var hasExtension = name && name.lastIndexOf('.') !== -1;
  42. if (hasExtension && !file.type) {
  43. var ext = name.split('.')
  44. .pop().toLowerCase();
  45. var type = exports.COMMON_MIME_TYPES.get(ext);
  46. if (type) {
  47. Object.defineProperty(file, 'type', {
  48. value: type,
  49. writable: false,
  50. configurable: false,
  51. enumerable: true
  52. });
  53. }
  54. }
  55. return file;
  56. }
  57. //# sourceMappingURL=file.js.map