Fix image upload field name: 'file' -> 'image'
All checks were successful
Build frontend / build (push) Successful in 40s

Endpoint expects field named 'image', returns path like /Pictures/abc123.jpg
This commit is contained in:
Claw AI
2026-03-30 01:15:57 +00:00
parent 8f700d0957
commit 505dcd4bb0
2 changed files with 27 additions and 15 deletions

View File

@ -201,7 +201,7 @@ export async function getCurrencies() {
export async function uploadPicture(file) {
console.log('[API] Uploading picture:', file.name);
const formData = new FormData();
formData.append('file', file);
formData.append('image', file);
const token = AuthService.getToken();
const res = await fetch(`${API_BASE}/Files/UploadPicture`, {
method: 'POST',
@ -213,7 +213,7 @@ export async function uploadPicture(file) {
const text = await res.text();
console.log('[API] Upload response:', res.status, text?.substring(0, 100));
if (!res.ok) throw new Error(`Upload failed: ${res.status} ${text}`);
// Response is the relative path string (possibly in envelope)
// Response is the relative path string (e.g. /Pictures/abc123.jpg)
try {
const json = JSON.parse(text);
return json?.data || json;