Improved uploader

This commit is contained in:
Eduard Urbach 2018-04-16 23:23:14 +02:00
parent d740cd0ddc
commit a8fad80990

View File

@ -55,8 +55,20 @@ function uploadFile(file: File, fileType: string, endpoint: string, arn: AnimeNo
let reader = new FileReader() let reader = new FileReader()
reader.onloadend = async () => { reader.onloadend = async () => {
let megaBytes = reader.result.byteLength / 1024 / 1024 let fileSize = reader.result.byteLength
arn.statusMessage.showInfo(`Uploading ${fileType}...${megaBytes.toFixed(1)} MB`, -1) let unit = "bytes"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "KB"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "MB"
}
}
arn.statusMessage.showInfo(`Uploading ${fileType}...${fileSize.toFixed(1)} ${unit}`, -1)
try { try {
let responseText = await fetchWithProgress(endpoint, { let responseText = await fetchWithProgress(endpoint, {