mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 20:53:45 +08:00
feat: images using object service storage
This commit is contained in:
19
app/client/platforms/utils.ts
Normal file
19
app/client/platforms/utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getAuthHeaders } from "../api";
|
||||
|
||||
export class FileApi {
|
||||
async upload(file: any): Promise<void> {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
var headers = getAuthHeaders();
|
||||
var res = await fetch("/api/file/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
...headers,
|
||||
},
|
||||
});
|
||||
const resJson = await res.json();
|
||||
console.log(resJson);
|
||||
return resJson.fileName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user