Withdrawn - #24
Closed
Kendrick-Bollens wants to merge 2 commits into
Closed
Conversation
added 2 commits
September 1, 2026 21:12
Adds get_images, get_image, create_image and delete_image, closing the gap
that made images the one kind of page content this server could not produce.
Attachments hang a file off a page; only a gallery image can be referenced
from the page body, and /api/image-gallery was unreachable from here.
create_image takes a path and returns the hosted URL plus BookStack's own
content.markdown / content.html snippets, so the caller embeds the result with
a normal update_page. The bytes never enter the conversation — the alternative,
inlining a data: URI, forces the model to *generate* ~1.37 bytes of base64 per
image byte as output tokens.
The upload deliberately goes through the existing axios instance rather than a
separate fetch path, so it inherits the concurrency semaphore, the 429
retry/backoff, the timeout and the TLS opt-out. That needs one per-request
override, `Content-Type: undefined`: the instance default is application/json,
and with it set axios never selects its form-data serializer. It JSON-encodes
the FormData instead, flattening the file to `"image":{}` — verified against a
local socket, which is what the resulting 422 actually means.
Two details taken from BookStack's source rather than assumed
(getImageValidationRules in app/Http/Controller.php):
['image_extension', 'mimes:jpeg,png,gif,webp,avif', 'max:' . (config('app.upload_limit') * 1000)]
so SVG is NOT an accepted gallery format and AVIF is. Format and size are
checked client-side to fail with an actionable message instead of an opaque 422,
and image errors now surface BookStack's response body.
create_image is registered on stdio only. It reads from the filesystem of the
machine running the server, which is meaningful only when that is the caller's
own machine. Over HTTP the server is remote and shared, so a caller-supplied
path would be an arbitrary-file-read primitive against the host; the capability
is threaded in separately from BookStackConfig because the HTTP path reuses the
same config objects across sessions.
Refs #11.
…riginal Verified live against BookStack 26.x: content.markdown returns .../gallery/2026-09/scaled-1680-/<file> while url is the original upload.
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.
Withdrawn.