add moment and child_process
This commit is contained in:
@ -84,6 +84,7 @@ export async function createFile(
|
||||
const file = await FileModel.create({
|
||||
uploader: uploader._id,
|
||||
fileId: fileId,
|
||||
originalFileName: fileName,
|
||||
uploadDate: new Date(),
|
||||
contentType: contentType,
|
||||
ext: extention,
|
||||
|
@ -14,3 +14,22 @@ export function randomString(length) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the given bytes formatted
|
||||
*
|
||||
* @param {Number} bytes The bytes amount
|
||||
* @param {Number} decimals The amount of decimals to show
|
||||
* @returns
|
||||
*/
|
||||
export function formatBytes(bytes, decimals = 2) {
|
||||
if (!+bytes) return "0 Bytes";
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
||||
}
|
||||
|
8
src/utils/helpers/webUtils.js
Normal file
8
src/utils/helpers/webUtils.js
Normal file
@ -0,0 +1,8 @@
|
||||
export function downloadURI(uri, name) {
|
||||
var link = document.createElement("a");
|
||||
link.download = name;
|
||||
link.href = uri;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
Reference in New Issue
Block a user