mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-21 22:50:59 -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 { modalController } from "../../../modals/ModalController";
|
||||
import { useClient } from "../../ClientController";
|
||||
import { clientController, useClient } from "../../ClientController";
|
||||
import { takeError } from "../error";
|
||||
|
||||
type BehaviourType =
|
||||
|
@ -67,9 +67,16 @@ export async function uploadFile(
|
|||
const formData = new FormData();
|
||||
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, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"X-Session-Token": sesToken,
|
||||
},
|
||||
...config,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue