feat(upload): support batching via header and update ShareX config
Introduce support for grouping multiple sequential file uploads into a single box using the `X-Warpbox-Batch` header. This is particularly useful for ShareX multi-file selections, which are sent as separate back-to-back requests.
Additionally, this change:
- Updates the ShareX configuration template to opt-in to batching by default.
- Switches ShareX configuration placeholders to the modern `{json:...}` format.
- Adds `thumbnailUrl` to the upload response schema and documents its usage.
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
</main>
|
||||
|
||||
<footer class="site-footer">
|
||||
<span>{{.AppName}} · {{.AppVersion}} · {{.CurrentYear}} · self-hosted</span>
|
||||
<span>{{.AppName}} · {{.AppVersion}} · {{.CurrentYear}}</span>
|
||||
<label class="theme-picker">
|
||||
<span>Theme</span>
|
||||
<select data-theme-select aria-label="Site theme">
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
<article class="card docs-card">
|
||||
<div class="card-content">
|
||||
<h2>JSON response</h2>
|
||||
<p>The raw delete token is returned only once inside <code>manageUrl</code> and <code>deleteUrl</code>. Keep those links private.</p>
|
||||
<p>The raw delete token is returned only once inside <code>manageUrl</code> and <code>deleteUrl</code>. Keep those links private. On error the body is <code>{ "error": "message" }</code> with a non-2xx status (e.g. rate limited or over a limit).</p>
|
||||
<pre><code>{
|
||||
"boxId": "abc123",
|
||||
"boxUrl": "{{.Data.BaseURL}}/d/abc123",
|
||||
"zipUrl": "{{.Data.BaseURL}}/d/abc123/zip",
|
||||
"thumbnailUrl": "{{.Data.BaseURL}}/d/abc123/thumb/file123",
|
||||
"manageUrl": "{{.Data.BaseURL}}/d/abc123/manage/private-token",
|
||||
"deleteUrl": "{{.Data.BaseURL}}/d/abc123/manage/private-token/delete",
|
||||
"expiresAt": "2026-06-05T12:00:00Z",
|
||||
@@ -49,7 +50,8 @@
|
||||
"id": "file123",
|
||||
"name": "report.pdf",
|
||||
"size": "2.4 MiB",
|
||||
"url": "{{.Data.BaseURL}}/d/abc123/f/file123"
|
||||
"url": "{{.Data.BaseURL}}/d/abc123/f/file123",
|
||||
"thumbnailUrl": "{{.Data.BaseURL}}/d/abc123/thumb/file123"
|
||||
}
|
||||
]
|
||||
}</code></pre>
|
||||
@@ -59,22 +61,44 @@
|
||||
<article class="card docs-card">
|
||||
<div class="card-content">
|
||||
<h2>ShareX setup</h2>
|
||||
<p>Import the uploader, then add your API key to upload as your account — with your account's size, daily, and retention limits — instead of as an anonymous guest.</p>
|
||||
|
||||
<h3>1 · Import the uploader</h3>
|
||||
<ol class="docs-steps">
|
||||
<li>Download the instance config: <a href="/api/v1/sharex/warpbox-anonymous.sxcu"><code>/api/v1/sharex/warpbox-anonymous.sxcu</code></a>.</li>
|
||||
<li>Or open the tracked template at <code>{{.Data.ShareXExamplePath}}</code> and change <code>RequestURL</code> to <code>{{.Data.ShareXExampleURL}}</code>.</li>
|
||||
<li>Keep <code>FileFormName</code> as <code>{{.Data.ShareXFileFieldName}}</code>.</li>
|
||||
<li>Import the <code>.sxcu</code> file into ShareX as a custom uploader.</li>
|
||||
<li>Upload a file. ShareX will use <code>boxUrl</code> as the public URL and <code>manageUrl</code> as the deletion URL.</li>
|
||||
<li>Download <a href="/api/v1/sharex/warpbox-anonymous.sxcu"><code>warpbox-anonymous.sxcu</code></a>.</li>
|
||||
<li>In ShareX: <code>Destinations → Custom uploader settings → Import → From file</code>, then pick the <code>.sxcu</code>.</li>
|
||||
</ol>
|
||||
|
||||
<h3>2 · Add your API key (upload as your account)</h3>
|
||||
<ol class="docs-steps">
|
||||
<li>Create a personal access token under <a href="/account/settings">Account → Access tokens</a> and copy it.</li>
|
||||
<li>In <code>Custom uploader settings</code>, select the Warpbox uploader and open the <code>Headers</code> section.</li>
|
||||
<li>Add a header — Name <code>Authorization</code>, Value <code>Bearer <your token></code>.</li>
|
||||
</ol>
|
||||
<p class="muted-copy">Without that header, uploads stay anonymous. With it, they're attributed to your account and use your account's limits.</p>
|
||||
|
||||
<pre><code>{
|
||||
"Version": "1.0.0",
|
||||
"Name": "Warpbox (my account)",
|
||||
"DestinationType": "ImageUploader, FileUploader, TextUploader",
|
||||
"RequestMethod": "POST",
|
||||
"RequestURL": "{{.Data.ShareXExampleURL}}",
|
||||
"Headers": { "Accept": "application/json" },
|
||||
"Headers": {
|
||||
"Accept": "application/json",
|
||||
"Authorization": "Bearer <span class="sxcu-highlight">YOUR_API_TOKEN</span>",
|
||||
"X-Warpbox-Batch": "sharex"
|
||||
},
|
||||
"Body": "MultipartFormData",
|
||||
"FileFormName": "{{.Data.ShareXFileFieldName}}",
|
||||
"URL": "$json:boxUrl$",
|
||||
"DeletionURL": "$json:manageUrl$"
|
||||
"URL": "{json:boxUrl}",
|
||||
"ThumbnailURL": "{json:thumbnailUrl}",
|
||||
"DeletionURL": "{json:deleteUrl}",
|
||||
"ErrorMessage": "{json:error}"
|
||||
}</code></pre>
|
||||
|
||||
<h3>Grouping multiple files into one box</h3>
|
||||
<p>Grouping is <strong>opt-in via the <code>X-Warpbox-Batch</code> request header</strong> — without it, every file becomes its own box (the default). When the header is present, uploads sharing the same value (per account, or per IP for anonymous) within {{.Data.ShareXGroupWindow}} of each other are added to the <strong>same</strong> box, so a multi-file ShareX selection produces one shareable link instead of one per file. The shipped config sets <code>X-Warpbox-Batch: sharex</code>; remove that header for one box per file.</p>
|
||||
<p class="muted-copy">The response also exposes <code>{json:thumbnailUrl}</code> for ShareX previews, <code>{json:deleteUrl}</code> for the deletion URL, and <code>{json:error}</code> so ShareX surfaces messages like rate limiting.</p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user