Skip to content

fileSizeFormat

Returns the given file size (in bytes) as a human-readable string.

Parameters

NameTypeRequiredDefault
bytesnumber
Converts it to a human-friendly string via the bytes provided here.
decimalsnamednumber2
Specifies the number of decimal places to represent.
ceilnamedbooleanfalse
If this value is true, the decimal point is removed and the number is rounded up.

named parameters are passed as named parameters in Dart and keyword arguments in Python.

Returns

string

Examples

javascript
fileSizeFormat(1000000); // '976.56 KB'
fileSizeFormat(100000000, 3); // '95.367 MB'
fileSizeFormat(100000000, 0, true); // '96 MB'
dart
fileSizeFormat(1000000); // '976.56 KB'
fileSizeFormat(100000000, decimals: 3); // '95.367 MB'
fileSizeFormat(100000000, ceil: true); // '96 MB'
python
fileSizeFormat(1000000)  # '976.56 KB'
fileSizeFormat(100000000, 3)  # '95.367 MB'
fileSizeFormat(100000000, 0, True)  # '96 MB'

Released under the MIT License