fix: upload image error
This commit is contained in:
parent
24de1bb77a
commit
e60c0f009b
|
@ -167,12 +167,15 @@ export class ClientApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHeaders() {
|
export function getHeaders(ignoreHeaders?: boolean) {
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
const headers: Record<string, string> = {
|
let headers: Record<string, string> = {};
|
||||||
"Content-Type": "application/json",
|
if (!ignoreHeaders) {
|
||||||
"x-requested-with": "XMLHttpRequest",
|
headers = {
|
||||||
};
|
"Content-Type": "application/json",
|
||||||
|
"x-requested-with": "XMLHttpRequest",
|
||||||
|
};
|
||||||
|
}
|
||||||
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
||||||
const isGoogle = modelConfig.model === "gemini-pro";
|
const isGoogle = modelConfig.model === "gemini-pro";
|
||||||
const isAzure = accessStore.provider === ServiceProvider.Azure;
|
const isAzure = accessStore.provider === ServiceProvider.Azure;
|
||||||
|
|
|
@ -4,7 +4,7 @@ export class FileApi {
|
||||||
async upload(file: any): Promise<void> {
|
async upload(file: any): Promise<void> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
var headers = getHeaders();
|
var headers = getHeaders(true);
|
||||||
var res = await fetch("/api/file/upload", {
|
var res = await fetch("/api/file/upload", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|
Loading…
Reference in New Issue