feat: support local storage

This commit is contained in:
Hk-Gosuto
2024-01-05 18:41:16 +08:00
parent 8e10354109
commit 296df592e0
18 changed files with 181 additions and 56 deletions

View File

@@ -1,11 +1,12 @@
import { getHeaders } from "../api";
export class FileApi {
async upload(file: any): Promise<void> {
async upload(file: any): Promise<any> {
const formData = new FormData();
formData.append("file", file);
var headers = getHeaders(true);
var res = await fetch("/api/file/upload", {
const api = "/api/file/upload";
var res = await fetch(api, {
method: "POST",
body: formData,
headers: {
@@ -14,6 +15,9 @@ export class FileApi {
});
const resJson = await res.json();
console.log(resJson);
return resJson.fileName;
return {
fileName: resJson.fileName,
filePath: resJson.filePath,
};
}
}