feat(server, web): quotas (#4471)
* feat: quotas * chore: open api * chore: update status box and upload error message --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Convert to bytes from on a specified unit.
|
||||
*
|
||||
* * `1, 'GiB'`, returns `1073741824` bytes
|
||||
*
|
||||
* @param size value to be converted
|
||||
* @param unit unit to convert from
|
||||
* @returns bytes (number)
|
||||
*/
|
||||
export function convertToBytes(size: number, unit: string): number {
|
||||
let bytes = 0;
|
||||
|
||||
if (unit === 'GiB') {
|
||||
bytes = size * 1073741824;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from bytes to a specified unit.
|
||||
*
|
||||
* * `11073741824, 'GiB'`, returns `1` GiB
|
||||
*
|
||||
* @param bytes value to be converted
|
||||
* @param unit unit to convert to
|
||||
* @returns bytes (number)
|
||||
*/
|
||||
export function convertFromBytes(bytes: number, unit: string): number {
|
||||
let size = 0;
|
||||
|
||||
if (unit === 'GiB') {
|
||||
size = bytes / 1073741824;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
Reference in New Issue
Block a user