Skip to content

feat(api): implement the Notes API v1.4 attachment endpoints - #17

Merged
gnacho merged 1 commit into
mainfrom
feat/issue-6-attachments
Sep 13, 2026
Merged

gnacho merged 1 commit into
mainfrom
feat/issue-6-attachments

Conversation

@gnacho

@gnacho gnacho commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Closes #6.

POST /index.php/apps/notes/api/v1.4/attachment/{noteId} stores the multipart file field and answers {"filename":".attachments.<noteId>/<name>"}, de-duplicating repeated names as name (1).ext. GET with ?path= streams the stored file with its detected content type.

Attachments are stored under the data dir keyed by note id, so the returned path is category-independent and deleting a note removes its attachments. The path is validated strictly against traversal, uploads are capped at 32 MiB, and the multipart body is capped before parsing.

There is no listing endpoint: the API spec has none, clients discover attachments from the note content.

Verification:

  • go build ./..., go vet ./... and go test -race ./... pass (9 new tests in the attachments package)
  • curl against the deployment: upload returns the documented path, repeated names de-duplicate, download returns the right bytes and content type, traversal and cross-note paths return 404, unauthenticated returns 401, unknown note returns 404, deleting the note removes its attachments, a 33 MiB upload returns 413
  • No regression: notes API 200/401, capabilities still advertises 1.4, ocnews untouched

POST /api/v1.4/attachment/{noteId} stores the multipart `file` field and
answers {"filename":".attachments.<noteId>/<name>"}, de-duplicating repeated
names as "name (1).ext". GET with ?path= streams the stored file with its
detected content type.

Attachments live under the data dir keyed by note id, so the returned path is
category-independent and deleting a note removes its attachments. Paths are
validated strictly against traversal, uploads are capped at 32 MiB and the
multipart body is capped before parsing.

Closes #6
@gnacho
gnacho merged commit 9f1de3c into main Sep 13, 2026
@gnacho
gnacho deleted the feat/issue-6-attachments branch September 13, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: attachment upload/serving for notes (API v1 attachment endpoints)

1 participant