Repository navigation
Conversation
added 3 commits
November 11, 2026 12:19
Addresses szabodanika#170: curl-based uploads currently get a 302 redirect, which forces every shell one-liner to scrape the Location header. Setting url_only_after_upload=true on the /upload multipart form now makes the server respond 200 OK with just the resulting upload URL as plain text, for every privacy level (public, unlisted, read-only and server-encrypted private). The URL follows the same short_path/public_path rules as the browser 'Copy URL' button, falling back to the incoming request's scheme/host when neither is configured, so it works out of the box without extra server configuration. Also documents curl-based uploads (file and content fields, avoiding the argument-list-too-long pitfall) and the new flag in the guide page.
…flag Command-line clients are now detected from the User-Agent header, so a plain upload already gets the scripting-friendly 200 OK + plain-text URL response instead of the browser redirect. url_only_after_upload=true is still available as an explicit opt-in for clients with an unrecognized or missing User-Agent.
…tion Previously the field only worked as an opt-in (OR'd with the curl/Wget/ HTTPie User-Agent auto-detection), so url_only_after_upload=false had no effect for an actual command-line client: the auto-detection would still force the plain-text URL response. url_only_after_upload is now parsed as Option<bool>: unset defers to the User-Agent heuristic as before, while an explicit true or false always wins, letting any client (including real curl) force either response mode for testing or integration purposes.
presto8
marked this pull request as ready for review
November 12, 2026 02:41
Build on rust:1-bookworm to match the distroless cc-debian12 runtime (rust:1 is now Debian 13, whose glibc is newer than the runtime's), and link liblzma statically via LZMA_API_STATIC since the distroless image does not ship it. Add a .dockerignore to keep target/, .git, local data and .env files out of the build context.
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.
What
Makes
/uploadscript-friendly for command-line clients, closing #170.url_only_after_uploadmultipart field. When set, the server responds200 OKwithContent-Type: text/plainand just the resulting upload URL, instead of the normal302redirect to the upload page.curl,Wget,HTTPie) viaUser-Agentand returns the same plain-text response automatically, with no extra flag needed for the common case.url_only_after_uploadis tri-state (Option<bool>): unset defers to the User-Agent auto-detection, while an explicittrue/falsealways overrides it — so a realcurlrequest can still force the normal redirect (e.g. for testing), and non-CLI/unrecognized clients can still opt in explicitly.MICROBIN_SHORT_PATH/MICROBIN_PUBLIC_PATHthe same way the "Copy URL" button does, falling back to the incoming request's scheme/host otherwise.templates/guide.htmlwithcurlexamples (file upload, text upload, forcing the response mode either way, and a sample shell function).Example
Testing
cargo buildsucceeds.curl/Wget/HTTPie-style requests, normal browser requests are unaffected, and expliciturl_only_after_upload=true/falseoverrides the auto-detection in both directions.Marked as draft pending maintainer review of the approach (in particular the User-Agent based auto-detection, which is a heuristic and not spoof-proof, though it only affects response formatting, nothing security-sensitive). Mirror of presto8#1.