Skip to content

Add ldh-AddFile op + FileClient for LDH file uploads#16

Merged
namedgraph merged 1 commit into
mainfrom
feat-ldh-add-file
Jun 14, 2026
Merged

Add ldh-AddFile op + FileClient for LDH file uploads#16
namedgraph merged 1 commit into
mainfrom
feat-ldh-add-file

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Summary

  • Adds ldh-AddFile operation that uploads a local file to a LinkedDataHub document using LDH's multipart RDF/POST dialect (same wire format as bin/add-file.sh)
  • Introduces FileClient, a sibling to LinkedDataClient, because files are bytes-with-Content-Type rather than RDF graphs — the graph-in/graph-out shape didn't fit. Multipart encoding is delegated to urllib3.filepost
  • Unlike the rest of the ldh-Add* family, ldh-AddFile doesn't subclass POST (different wire format) and owns its FileClient instance directly
  • Returns a JSONResult with the minted <base>/uploads/{sha1} URI and HTTP status; takes a target document URI, local file path, title, optional description, optional MIME override

Test plan

  • Unit tests in tests/unit/test_ldh_add_file.py pass
  • Smoke test against a live LDH instance with a real cert
  • Confirm formal-semantics.md entry renders correctly

Files are not Linked Data — request bodies are bytes with a Content-Type
rather than RDF graphs — so LinkedDataClient's graph-in/graph-out shape
doesn't fit. FileClient is a sibling client carrying its own SSL/opener
setup, exposing add_file() which RDF/POSTs a file to a target LDH document
using LDH's multipart RDF/POST dialect (the same encoding bin/add-file.sh
uses). Multipart body construction delegates to urllib3.filepost so we
don't maintain hand-rolled encoding.

ldh-AddFile is the Web-Algebra surface: takes a target document URI, a
local file path, a title, optional description, optional MIME override.
Returns a JSONResult with the minted <base>/uploads/{sha1} URI and the
HTTP status. Unlike the rest of the ldh-Add* family it doesn't subclass
POST — different wire format — so it owns its FileClient instance directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@namedgraph namedgraph merged commit 476a6a2 into main Jun 14, 2026
6 checks passed
@namedgraph namedgraph deleted the feat-ldh-add-file branch June 14, 2026 16:08
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.

1 participant