mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-26 00:50:56 -05:00
feat: add session token to file uploads
This commit is contained in:
parent
c972e6813f
commit
df4f6578f7
1 changed files with 8 additions and 1 deletions
|
@ -12,7 +12,7 @@ import { IconButton, Preloader } from "@revoltchat/ui";
|
||||||
import { determineFileSize } from "../../../../lib/fileSize";
|
import { determineFileSize } from "../../../../lib/fileSize";
|
||||||
|
|
||||||
import { modalController } from "../../../modals/ModalController";
|
import { modalController } from "../../../modals/ModalController";
|
||||||
import { useClient } from "../../ClientController";
|
import { clientController, useClient } from "../../ClientController";
|
||||||
import { takeError } from "../error";
|
import { takeError } from "../error";
|
||||||
|
|
||||||
type BehaviourType =
|
type BehaviourType =
|
||||||
|
@ -67,9 +67,16 @@ export async function uploadFile(
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
|
const client = clientController.getActiveSession()?.client;
|
||||||
|
const sesToken =
|
||||||
|
typeof client?.session === "string"
|
||||||
|
? client.session
|
||||||
|
: client?.session?.token;
|
||||||
|
|
||||||
const res = await Axios.post(`${autumnURL}/${tag}`, formData, {
|
const res = await Axios.post(`${autumnURL}/${tag}`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
|
"X-Session-Token": sesToken,
|
||||||
},
|
},
|
||||||
...config,
|
...config,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue