mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-25 15:10:17 +09:00
24 lines
536 B
TypeScript
24 lines
536 B
TypeScript
import { getHeaders } from "../api";
|
|
|
|
export class FileApi {
|
|
async upload(file: any): Promise<any> {
|
|
const formData = new FormData();
|
|
formData.append("file", file);
|
|
var headers = getHeaders(true);
|
|
const api = "/api/file/upload";
|
|
var res = await fetch(api, {
|
|
method: "POST",
|
|
body: formData,
|
|
headers: {
|
|
...headers,
|
|
},
|
|
});
|
|
const resJson = await res.json();
|
|
console.log(resJson);
|
|
return {
|
|
fileName: resJson.fileName,
|
|
filePath: resJson.filePath,
|
|
};
|
|
}
|
|
}
|