Gazebo_simulation-Frontend/node_modules/file-selector/dist/file.js

57 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-12-21 11:29:31 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.COMMON_MIME_TYPES = new Map([
['avi', 'video/avi'],
['gif', 'image/gif'],
['ico', 'image/x-icon'],
['jpeg', 'image/jpeg'],
['jpg', 'image/jpeg'],
['mkv', 'video/x-matroska'],
['mov', 'video/quicktime'],
['mp4', 'video/mp4'],
['pdf', 'application/pdf'],
['png', 'image/png'],
['zip', 'application/zip'],
['doc', 'application/msword'],
['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
]);
function toFileWithPath(file, path) {
var f = withMimeType(file);
if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path
var webkitRelativePath = file.webkitRelativePath;
Object.defineProperty(f, 'path', {
value: typeof path === 'string'
? path
// If <input webkitdirectory> is set,
// the File will have a {webkitRelativePath} property
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
: typeof webkitRelativePath === 'string' && webkitRelativePath.length > 0
? webkitRelativePath
: file.name,
writable: false,
configurable: false,
enumerable: true
});
}
return f;
}
exports.toFileWithPath = toFileWithPath;
function withMimeType(file) {
var name = file.name;
var hasExtension = name && name.lastIndexOf('.') !== -1;
if (hasExtension && !file.type) {
var ext = name.split('.')
.pop().toLowerCase();
var type = exports.COMMON_MIME_TYPES.get(ext);
if (type) {
Object.defineProperty(file, 'type', {
value: type,
writable: false,
configurable: false,
enumerable: true
});
}
}
return file;
}
//# sourceMappingURL=file.js.map