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