added test image upload

This commit is contained in:
2024-04-20 17:36:18 +07:00
parent 4dbb67d5fc
commit 4a11cf0f94
4 changed files with 66 additions and 1 deletions

8
src/utils/fileUpload.js Normal file
View File

@@ -0,0 +1,8 @@
export function createFormData(request, file) {
const formData = new FormData();
Object.entries(request.formData).forEach(([key, value]) => {
formData.append(key, value);
});
formData.append("file", file, file.name);
return formData;
}

View File

@@ -5,6 +5,12 @@ export const client = createTRPCProxyClient({
links: [
httpBatchLink({
url: CONFIG.api_url,
headers: () => {
let token = localStorage.getItem("token");
return {
Authorization: token ? `Bearer ${token}` : "",
};
},
}),
],
});