(bytes: number)
| 169 | } |
| 170 | |
| 171 | function formatBytes(bytes: number): string { |
| 172 | if (!bytes) return ""; |
| 173 | |
| 174 | const units = ["B", "KB", "MB", "GB"]; |
| 175 | let value = bytes; |
| 176 | let unitIndex = 0; |
| 177 | |
| 178 | while (value >= 1024 && unitIndex < units.length - 1) { |
| 179 | value /= 1024; |
| 180 | unitIndex++; |
| 181 | } |
| 182 | |
| 183 | return `${value.toFixed(value >= 10 || unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`; |
| 184 | } |
| 185 | |
| 186 | const ProgressBarInner = () => { |
| 187 | const [state, setState] = useState(getUploadState); |