Improved uploader
This commit is contained in:
parent
d740cd0ddc
commit
a8fad80990
@ -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, {
|
||||||
|
Loading…
Reference in New Issue
Block a user