import type { IResponse } from "."; const putFile = (file: File, url: string): Promise => { return new Promise((resolve, reject) => { $fetch(url, { method: "PUT", body: file, headers: { "Content-Type": file.type, }, }) .then(() => { resolve(url.split("?")[0]); }) .catch(() => { reject(new Error("File upload failed")); }); }); }; export const uploadFile = async (file: File, type: "resource" | "temp") => { const signedUrl = await http>( `/common/oss/getSignUrl`, { method: "POST", query: { fileName: encodeURI(file.name), fileType: type, fileSize: file.size, fileMime: file.type, }, } ); const url = signedUrl.data; return await putFile(file, url); };