add upload content type

This commit is contained in:
Jordan Blasenhauer 2024-04-16 13:31:15 +02:00
parent 0977429824
commit 00b2d75735

View file

@ -314,11 +314,21 @@ class Upload {
let name = file.name;
if (name.length >= 12) {
let splitName = name.split(".");
// get extension
const allowExt = ["zip", ".tar.gz", ".tar.xz"];
let ext = null;
allowExt.forEach((el) => {
// check if allow ext in name
if (name.includes(el)) {
ext = el;
}
});
name = splitName[0].substring(0, 13) + "... ." + splitName[1];
}
let xhr = new XMLHttpRequest();
xhr.open("POST", "plugins/upload");
xhr.setRequestHeader("Content-Type", `application/${ext}`);
let fileSize;
xhr.upload.addEventListener("progress", ({ loaded, total }) => {