feat: images using object service storage

This commit is contained in:
Hk-Gosuto
2023-12-10 21:23:40 +08:00
parent b84da5e120
commit 600a7d2197
6 changed files with 142 additions and 28 deletions

View 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;
}
}