mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-14 13:19:05 +03:00
27 lines
680 B
TypeScript
27 lines
680 B
TypeScript
import { AxiosInstance } from "axios";
|
|
import { UUID } from "crypto";
|
|
|
|
import { ToastData } from "@/lib/components/ui/Toast/domain/types";
|
|
|
|
export type UploadResponse = {
|
|
data: { type: ToastData["variant"]; message: ToastData["text"] };
|
|
};
|
|
|
|
export type UploadInputProps = {
|
|
brainId: UUID;
|
|
formData: FormData;
|
|
chat_id?: UUID;
|
|
};
|
|
|
|
export const uploadFile = async (
|
|
props: UploadInputProps,
|
|
axiosInstance: AxiosInstance
|
|
): Promise<UploadResponse> => {
|
|
let uploadUrl = `/upload?brain_id=${props.brainId}`;
|
|
if (props.chat_id !== undefined) {
|
|
uploadUrl = uploadUrl.concat(`&chat_id=${props.chat_id}`);
|
|
}
|
|
|
|
return axiosInstance.post(uploadUrl, props.formData);
|
|
};
|