fix: bugs in general

This commit is contained in:
2026-04-29 02:35:23 +03:00
parent e330fb04b3
commit fb80f11e72
6 changed files with 211 additions and 46 deletions

View File

@@ -1,15 +1,14 @@
<h3>Upload with cURL</h3>
<p>WarpBox accepts normal multipart form uploads through the compatibility endpoint:</p>
<code class="code-block">curl \
<h3>Upload from a terminal</h3>
<p>WarpBox accepts normal multipart uploads at <code>/upload</code>. The server returns JSON with a <code>box_url</code> you can open or share.</p>
<pre class="code-block"><code>curl \
-F 'files=@./my-file.zip' \
-F 'retention=1h' \
{{ origin }}/upload
</code>
<h4>Browser flow</h4>
<p>The browser uses the manifest API: it creates a box, uploads each file, and marks failed uploads so the download page does not wait forever.</p>
<h4>Make a WarpBox executable</h4>
<p>Save this as <code>warpbox</code>, make it executable, and put it somewhere on your <code>PATH</code>.</p>
<code class="code-block">#!/usr/bin/env bash
</code></pre>
<h4>Reusable shell wrapper</h4>
<p>This version is small, portable, and works well as a personal <code>warpbox</code> command.</p>
<pre class="code-block"><code>#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -lt 1 ]; then
@@ -25,9 +24,39 @@ for file in "$@"; do
args+=(-F "files=@${file}")
done
curl "${args[@]}" "${endpoint}"
</code>
<code class="code-block">chmod +x ./warpbox
curl --fail-with-body "${args[@]}" "${endpoint}"
</code></pre>
<h4>Install it</h4>
<p>Put the wrapper somewhere on your <code>PATH</code>, then call it with one or more files.</p>
<pre class="code-block"><code>chmod +x ./warpbox
sudo install -m 755 ./warpbox /usr/local/bin/warpbox
warpbox ./my-file.zip
</code>
warpbox ./photo.png ./archive.zip
</code></pre>
<h4>Print only the share URL</h4>
<p>If <code>jq</code> is installed, this variant extracts the returned link and expands it to a full URL.</p>
<pre class="code-block"><code>warpbox() {
local endpoint="${WARPBOX_URL:-{{ origin }}}/upload"
local retention="${WARPBOX_RETENTION:-1h}"
local args=(-F "retention=${retention}")
for file in "$@"; do
args+=(-F "files=@${file}")
done
curl --fail-with-body -sS "${args[@]}" "${endpoint}" |
jq -r --arg origin "${WARPBOX_URL:-{{ origin }}}" '"\($origin)\(.box_url)"'
}
</code></pre>
<h4>Add password or retention</h4>
<p>You can keep the wrapper simple and pass fixed options through environment variables or extra form fields.</p>
<pre class="code-block"><code>WARPBOX_RETENTION=24h warpbox ./release.tar.gz
curl \
-F 'files=@./private.zip' \
-F 'retention=1h' \
-F 'password=correct-horse-battery-staple' \
{{ origin }}/upload
</code></pre>

View File

@@ -1,20 +1,20 @@
<h3>Upload examples</h3>
<h4>Basic CLI upload</h4>
<code class="code-block">curl \
<pre class="code-block"><code>curl \
-F 'files=@./photo.png' \
-F 'retention=24h' \
{{ origin }}/upload
</code>
</code></pre>
<h4>Multiple files with password</h4>
<code class="code-block">curl \
<pre class="code-block"><code>curl \
-F 'files=@./one.png' \
-F 'files=@./two.zip' \
-F 'retention=1h' \
-F 'password=secret-pass' \
{{ origin }}/upload
</code>
</code></pre>
<h4>Go</h4>
<code class="code-block">package main
<pre class="code-block"><code>package main
import (
"bytes"
@@ -48,9 +48,9 @@ func main() {
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}
</code>
</code></pre>
<h4>Java 11+ HttpClient</h4>
<code class="code-block">import java.net.URI;
<pre class="code-block"><code>import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
@@ -84,9 +84,9 @@ public class UploadWarpBox {
System.out.println(response.body());
}
}
</code>
</code></pre>
<h4>JavaScript Node.js</h4>
<code class="code-block">import { openAsBlob } from 'node:fs';
<pre class="code-block"><code>import { openAsBlob } from 'node:fs';
const file = await openAsBlob('./photo.png');
const form = new FormData();
@@ -99,4 +99,4 @@ const res = await fetch('{{ origin }}/upload', {
});
console.log(await res.text());
</code>
</code></pre>