react-drag-drop-files
Version:
Light React Drag & Drop files and images library styled by styled-components
37 lines • 949 B
JavaScript
/**
* Converting the file size to MB
* @param size : Size to be converted;
* @returns number
*
* @internal
*/
export var getFileSizeMB = function (size) {
return size / 1024 / 1024;
};
/**
*
* Check if the file uploaded is in the type list or not
* @param file - The File uploaded
* @param types - Available types
* @returns boolean
*
* @internal
*/
export var checkType = function (file, types) {
var extension = file.name.split('.').pop();
var loweredTypes = types.map(function (type) { return type.toLowerCase(); });
return loweredTypes.includes(extension.toLowerCase());
};
/**
* Get the files for input "accept" attribute
* @param types - Allowed types
* @returns string
*
* @internal
*/
export var acceptedExt = function (types) {
if (types === undefined)
return '';
return types.map(function (type) { return ".".concat(type.toLowerCase()); }).join(',');
};
//# sourceMappingURL=utils.js.map