ref: 统一ftp操作功能,备份文件查看下载删除功能
This commit is contained in:
@@ -101,7 +101,14 @@ export function parseObjLineToHump(obj: any): any {
|
||||
* @param decimalPlaces 保留小数位,默认2位
|
||||
* @returns 单位 xB
|
||||
*/
|
||||
export function parseSizeFromFile(bytes: number, decimalPlaces: number = 2) {
|
||||
export function parseSizeFromFile(
|
||||
bytes: number,
|
||||
decimalPlaces: number = 2
|
||||
): string {
|
||||
if (typeof bytes !== 'number' || isNaN(bytes) || bytes < 0) {
|
||||
return `${bytes}`;
|
||||
}
|
||||
if (bytes === 0) return '0 B';
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
let i = 0;
|
||||
while (bytes >= 1024 && i < units.length - 1) {
|
||||
|
||||
Reference in New Issue
Block a user