feat(api): direct multipart upload endpoints for filesystem backend #136

Merged
forbes merged 1 commits from feat-direct-upload into main 2026-02-17 19:05:40 +00:00
Owner

Summary

Add direct multipart upload endpoints that bypass the MinIO presigned URL flow, enabling the filesystem storage backend to handle file uploads.

Backend

  • POST /api/items/{pn}/files/upload — multipart file upload, writes to storage, creates DB record with storage_backend
  • POST /api/items/{pn}/thumbnail/upload — multipart thumbnail upload, writes to storage, updates thumbnail_key in DB
  • GET /api/items/{pn}/files/{fileId}/download — streams file from storage with Content-Disposition: attachment header
  • Helper storageBackend() reads configured backend from config

Frontend

  • Rewrote useFileUpload.ts: presign+XHR PUT → direct multipart FormData POST via XHR (progress tracking preserved)
  • Updated CreateItemPane.tsx: files held in browser memory on drop, uploaded after item creation via new endpoints
  • Thumbnail preview shown immediately on file select (no upload needed first)

Backward compatibility

The old presign + associate endpoints (POST /api/uploads/presign, POST /api/items/{pn}/files, PUT /api/items/{pn}/thumbnail) remain functional for MinIO deployments.

Closes #129

## Summary Add direct multipart upload endpoints that bypass the MinIO presigned URL flow, enabling the filesystem storage backend to handle file uploads. ### Backend - `POST /api/items/{pn}/files/upload` — multipart file upload, writes to storage, creates DB record with `storage_backend` - `POST /api/items/{pn}/thumbnail/upload` — multipart thumbnail upload, writes to storage, updates `thumbnail_key` in DB - `GET /api/items/{pn}/files/{fileId}/download` — streams file from storage with `Content-Disposition: attachment` header - Helper `storageBackend()` reads configured backend from config ### Frontend - Rewrote `useFileUpload.ts`: presign+XHR PUT → direct multipart FormData POST via XHR (progress tracking preserved) - Updated `CreateItemPane.tsx`: files held in browser memory on drop, uploaded after item creation via new endpoints - Thumbnail preview shown immediately on file select (no upload needed first) ### Backward compatibility The old presign + associate endpoints (`POST /api/uploads/presign`, `POST /api/items/{pn}/files`, `PUT /api/items/{pn}/thumbnail`) remain functional for MinIO deployments. Closes #129
forbes added 1 commit 2026-02-17 19:05:01 +00:00
Add three new endpoints that bypass the MinIO presigned URL flow:
- POST /api/items/{pn}/files/upload — multipart file upload
- POST /api/items/{pn}/thumbnail/upload — multipart thumbnail upload
- GET /api/items/{pn}/files/{fileId}/download — stream file download

Rewrite frontend upload flow: files are held in browser memory on drop
and uploaded directly after item creation via multipart POST. The old
presign+associate endpoints remain for MinIO backward compatibility.

Closes #129
forbes merged commit 8cd92a4025 into main 2026-02-17 19:05:40 +00:00
forbes deleted branch feat-direct-upload 2026-02-17 19:05:40 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#136