Formats a file dump's size and name for display, in the file fields, the previews and the dump creation dialog.

Functions

f
formatBytes(bytes: number): string

Returns bytes as a size in bytes, kilobytes or megabytes, where a kilobyte is 1024 bytes, in the app's language ("1.5 kB", "1,5 ko"). Intl names the units, so they follow the language without a catalog.

f
titleFromFileName(name: string): string

Returns the file name name as the title the dump creation dialog proposes. The extension goes, since the dump keeps its MIME type, and runs of underscores become spaces, so holiday_photo-01.final.jpg reads as holiday photo-01.final. A name that is only an extension (.gitignore) stays as it is.