pyro: multipart mrpack uploads (#2917)

* chore: impl in pyroservers

Signed-off-by: Evan Song <theevansong@gmail.com>

* chore: disable install btn if loading

Signed-off-by: Evan Song <theevansong@gmail.com>

---------

Signed-off-by: Evan Song <theevansong@gmail.com>
This commit is contained in:
Evan Song 2024-11-05 15:24:13 -07:00 committed by GitHub
parent d0efa44c9e
commit deb16aa7ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -47,9 +47,12 @@ async function PyroFetch<T>(path: string, options: PyroFetchOptions = {}): Promi
"Access-Control-Allow-Headers": "Authorization",
"User-Agent": "Pyro/1.0 (https://pyro.host)",
Vary: "Accept, Origin",
"Content-Type": contentType,
};
if (contentType !== "none") {
headers["Content-Type"] = contentType;
}
if (import.meta.client && typeof window !== "undefined") {
headers.Origin = window.location.origin;
}
@ -396,10 +399,13 @@ const reinstallFromMrpack = async (mrpack: File, hardReset: boolean = false) =>
`servers/${internalServerRefrence.value.serverId}/reinstallFromMrpack`,
);
return await PyroFetch(`/reinstallMrpack?hard=${hardResetParam}`, {
const formData = new FormData();
formData.append("file", mrpack);
return await PyroFetch(`/reinstallMrpackMultiparted?hard=${hardResetParam}`, {
method: "POST",
contentType: "application/octet-stream",
body: mrpack,
contentType: "none",
body: formData,
override: auth,
});
} catch (error) {

View File

@ -103,7 +103,7 @@
/>
<div class="mt-4 flex justify-start gap-4">
<ButtonStyled :color="isDangerous ? 'red' : 'brand'">
<button :disabled="!mrpackFile" @click="reinstallMrpack">
<button :disabled="!mrpackFile || isLoading" @click="reinstallMrpack">
<RightArrowIcon />
{{
isSecondPhase