Add ldh-AddFile op + FileClient for LDH file uploads#16
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ldh-AddFileoperation that uploads a local file to a LinkedDataHub document using LDH's multipart RDF/POST dialect (same wire format asbin/add-file.sh)FileClient, a sibling toLinkedDataClient, because files are bytes-with-Content-Type rather than RDF graphs — the graph-in/graph-out shape didn't fit. Multipart encoding is delegated tourllib3.filepostldh-Add*family,ldh-AddFiledoesn't subclassPOST(different wire format) and owns itsFileClientinstance directlyJSONResultwith the minted<base>/uploads/{sha1}URI and HTTP status; takes a target document URI, local file path, title, optional description, optional MIME overrideTest plan
tests/unit/test_ldh_add_file.pypassformal-semantics.mdentry renders correctly