Skip to content

Commit

Permalink
feat: add session token to file uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Oct 27, 2024
1 parent c972e68 commit df4f657
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/controllers/client/jsx/legacy/FileUploads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
});
Expand Down

0 comments on commit df4f657

Please sign in to comment.