Skip to content

Commit

Permalink
pyro: multipart mrpack uploads (#2917)
Browse files Browse the repository at this point in the history
* chore: impl in pyroservers

Signed-off-by: Evan Song <[email protected]>

* chore: disable install btn if loading

Signed-off-by: Evan Song <[email protected]>

---------

Signed-off-by: Evan Song <[email protected]>
  • Loading branch information
ferothefox authored Nov 5, 2024
1 parent d0efa44 commit deb16aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions apps/frontend/src/composables/pyroServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit deb16aa

Please sign in to comment.