sharex-upload-server
sharex-upload-server copied to clipboard
A lightweight, dependency-less ShareX upload server in Node.js
sharex-upload-server
A lightweight, dependency-less ShareX upload server in Node.js
Instructions
Setting up the server
git clone https://github.com/aetheryx/sharex-upload-server
cd sharex-upload-server
npm run -s generate-key # save the output of this command
pm2 start ./src/index.js --name sharex # or whatever node process manager you want to use!
The configuration file
The default config.json
has fairly sensible defaults (after you run npm run -s generate-key
), but it might be worthwhile to take a look at what you can configure.
config.port
The port the HTTP server runs on. ¯\_(ツ)_/¯
config.key
The authorization header the server expects for authorized requests. Automatically generated for you with npm run -s generate-key
.
config.fileIDLength
The length of the file identifier (the request path, the bit after your actual domain). Default is 3
. Make sure you're familiar with your config.format
to know what this should be for you personally.
config.format
The format of the file identifier. There are two options available - base62
(default) and zws
.
base62
is fairly self explanatory. It's a format of 62 possible characters (a-z
, A-Z
, 0-9
). You don't need a high fileIDLength
when using base62
, the default fileIDLength
already gives you 238,328 (62^3
) possible files.
zws
is a format inspired by zws.im. The format only contains five possible characters, so you need a higher fileIDLength
than you would with base62
. You can calculate 5^n
where n
is your fileIDLength
to see how many files you could store. The advantage of this format is that all of the characters are invisible, making it look like the link is just your domain. On the other hand, typing out the URL manually is basically impossible - you have to copy it to share it.
Setting up ShareX
- Go to Destinations -> Custom Uploader Settings
- Press the New button, give the entry a name, and tick these destination types
- On the Request tab,
-
Set the method to POST
-
Enter the URL of your domain
-
Set the body to Binary
-
Add a header with the key being "Authorization" and the value being your key from the
npm run -s generate-key
commandEnd result should look something like this
-
- On the Response tab, set the URL to your domain and then append
$json:.filename$
. - Make sure you set the Destination entries to their respective "Custom" options.
Setting up Flameshot
Flameshot is a popular Linux screenshot tool. Here's a wrapper script that pipes your screenshot directly to the file server:
domain="https://example.com" # Change to your own domain
token="Tp1f9JSFEczdGJ5/eY7TfIWdrLeMWUqt2VC4kSWY/2o=" # Change to your own token
screenshot() {
flameshot gui -r
}
upload() {
curl -s \
-X POST \
-H "Authorization: $token" \
-H "Content-Type: image/png" \
--data-binary @- \
"$domain"
}
copy() {
xclip -sel c
}
filename=$(screenshot | upload | jq -r '.filename')
echo "$domain/$filename" | copy