Converting file size in bytes to human-readable string

后端 未结 19 2148
眼角桃花
眼角桃花 2020-11-28 17:58

I\'m using this function to convert a file size in bytes to a human-readable file size:

function getReadableFileSizeString(fileSizeInBytes) {
    var i = -1;         


        
19条回答
  •  庸人自扰
    2020-11-28 18:33

    let bytes = 1024 * 10 * 10 * 10;

    console.log(getReadableFileSizeString(bytes))

    will return 1000.0Кб instead of 1MB

提交回复
热议问题