Fix 404: use /gradio_api/upload path + gradio.FileData meta wrapper
Browse filesThe upload endpoint is under the /gradio_api/ prefix, not at the root.
Also wraps the file data in {meta: {_type: 'gradio.FileData'}} per the
Gradio 5.x REST API format that @gradio/client uses internally.
- src/lib/services/scan.ts +2 -2
src/lib/services/scan.ts
CHANGED
|
@@ -17,7 +17,7 @@ export async function scanPhoto(image: File, hfToken: string): Promise<ScanResul
|
|
| 17 |
// 1. Upload the image to Gradio's file upload endpoint
|
| 18 |
const formData = new FormData();
|
| 19 |
formData.append('files', image);
|
| 20 |
-
const uploadResp = await fetch(`${BACKEND_URL}/upload`, {
|
| 21 |
method: 'POST',
|
| 22 |
body: formData,
|
| 23 |
credentials: 'omit',
|
|
@@ -36,7 +36,7 @@ export async function scanPhoto(image: File, hfToken: string): Promise<ScanResul
|
|
| 36 |
headers: { 'Content-Type': 'application/json' },
|
| 37 |
body: JSON.stringify({
|
| 38 |
data: [
|
| 39 |
-
{ path: filePath, orig_name: image.name, mime_type: image.type },
|
| 40 |
hfToken,
|
| 41 |
],
|
| 42 |
}),
|
|
|
|
| 17 |
// 1. Upload the image to Gradio's file upload endpoint
|
| 18 |
const formData = new FormData();
|
| 19 |
formData.append('files', image);
|
| 20 |
+
const uploadResp = await fetch(`${BACKEND_URL}/gradio_api/upload`, {
|
| 21 |
method: 'POST',
|
| 22 |
body: formData,
|
| 23 |
credentials: 'omit',
|
|
|
|
| 36 |
headers: { 'Content-Type': 'application/json' },
|
| 37 |
body: JSON.stringify({
|
| 38 |
data: [
|
| 39 |
+
{ path: filePath, orig_name: image.name, mime_type: image.type, meta: { _type: 'gradio.FileData' } },
|
| 40 |
hfToken,
|
| 41 |
],
|
| 42 |
}),
|