Files
WarpBox/static/popups/cli.html
Daniel Legt ac6e8c591b feat(ui): add reusable warpbox wrapper and improve upload documentation
Updated static/popups/cli.html with clearer upload instructions, added a reusable warpbox shell wrapper with install steps and a function for printing the share URL, making the command more accessible and portable.
2026-04-29 11:51:04 +03:00

82 lines
3.8 KiB
HTML

<h3><u>Upload Files from Terminal</u></h3>
<p>WarpBox accepts normal multipart uploads at <strong><u>/upload</u></strong>. The server returns JSON with a <code>box_url</code> you can open or share.</p>
<div style="background:#ffffff; border-top:1px solid #808080; border-left:1px solid #808080; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; padding:10px; margin:10px 0;">
<p><strong>> Quick Upload:</strong> Use this command to upload a single file:</p>
<pre class="code-block"><code>curl \
-F 'files=@./my-file.zip' \
-F 'retention=1h' \
{{ origin }}/upload</code></pre>
</div>
<h4><u>Reusable Shell Wrapper</u></h4>
<p>This version is small, portable, and works well as a personal <strong><u>warpbox</u></strong> command.</p>
<div style="background:#ffffff; border-top:1px solid #808080; border-left:1px solid #808080; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; padding:10px; margin:10px 0;">
<p><strong>> Save this as a file</strong> called <strong><u>warpbox</u></strong> and make it executable to use it as a command:</p>
<pre class="code-block"><code>#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -lt 1 ]; then
echo "Usage: warpbox FILE [FILE ...]" >&2
exit 64
fi
endpoint="${WARPBOX_URL:-{{ origin }}}/upload"
retention="${WARPBOX_RETENTION:-1h}"
args=(-F "retention=${retention}")
for file in "$@"; do
args+=(-F "files=@${file}")
done
curl --fail-with-body "${args[@]}" "${endpoint}"</code></pre>
</div>
<h4><u>Install the Command</u></h4>
<p>Put the wrapper somewhere on your <code>PATH</code>, then call it with one or more files.</p>
<div style="background:#ffffff; border-top:1px solid #808080; border-left:1px solid #808080; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; padding:10px; margin:10px 0;">
<p><strong>> Install Steps:</strong></p>
<ol>
<li>Make the script executable: <code>chmod +x ./warpbox</code></li>
<li>Install to system path: <code>sudo install -m 755 ./warpbox /usr/local/bin/warpbox</code></li>
<li>Use it: <code>warpbox ./photo.png ./archive.zip</code></li>
</ol>
</div>
<h4><u>Print Only the Share URL</u></h4>
<p>If <strong><u>jq</u></strong> is installed, this variant extracts the returned link and expands it to a full URL.</p>
<div style="background:#ffffff; border-top:1px solid #808080; border-left:1px solid #808080; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; padding:10px; margin:10px 0;">
<p><strong>> Function Version:</strong> Add this function to your shell profile (like <strong><u>~/.bashrc</u></strong> or <strong><u>~/.zshrc</u></strong>):</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>
</div>
<h4><u>Add Password or Retention</u></h4>
<p>You can keep the wrapper simple and pass fixed options through <strong><u>environment variables</u></strong> or extra form fields.</p>
<div style="background:#ffffff; border-top:1px solid #808080; border-left:1px solid #808080; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; padding:10px; margin:10px 0;">
<p><strong>> Examples:</strong></p>
<p>Set <u>retention period</u> for one upload:</p>
<pre class="code-block"><code>WARPBOX_RETENTION=24h warpbox ./release.tar.gz</code></pre>
<p>Add <u>password protection</u> to a specific upload:</p>
<pre class="code-block"><code>curl \
-F 'files=@./private.zip' \
-F 'retention=1h' \
-F 'password=correct-horse-battery-staple' \
{{ origin }}/upload</code></pre>
</div>