Skip to content

Setting up ShareX

Alexis Tan edited this page Jul 1, 2021 · 3 revisions

This guide assumes you already have a running version of the ShareX Media Server, if you don't have a media server setup you can follow the installation guide.

Table of Content

Creating API Token

Before you start, you'll first need to create an API token that can be used with ShareX requests, the API token is used to validate your image, file/text snippet uploads, and URL shortening requests, to ensure you're actually allowed to upload files.

To create an API token you can click on your account name in the navigation in the top right of the app, and then click on the API Tokens menu item, this should move you to a page where you can create your own token, from there give the token a name, and make sure that you tick the upload permissions so the API token has the permissions to upload files to the media server.

ShareX Media Server - Creating an API token

After clicking on Create you'll get a popup with your newly created API token, make sure to copy it so you have it for later, since it won't ever be shown to you again.

Creating Custom ShareX Uploader

To setup a custom ShareX uploader you can navigate to: Destinations -> Custom Uploader Settings in the ShareX app.

From there create a new custom uploader, to setup everything we have to do a few things.

  1. Set the request method to POST.
  2. Set the URL to the root of your media server, followed by the API endpoint for the type of uploader you're setting up, example /api/images for images.
  3. Add an Authorization header to the request, and set the value to Bearer <your API token>
  4. Set the "File from name" value to match what you're uploading, for images it would be image, for text files it should be file, and for URL shortening it should be url.
  5. Finally, click on the response tab, select the JSON option and set the URL to $json:resource_url$, this will select the resource URL being generated by the API during the upload and make it available to you so you can copy it to your clipboard.

It should all look something like this.

Response Page Example

ShareX Media Server - Response page example

Image Request Example

ShareX Media Server - Image request example

File Request Example

ShareX Media Server - Text & Files request example

If you don't want to link to the resource information page after uploading files via ShareX, you can instead change $json:resource_url$ to $json:preview_url$ under the "Parse response" section, which will point to the preview URL instead.

Text Request Example

ShareX Media Server - Text & Files request example

URLs Request Example

ShareX Media Server - URLs request example

Importing ShareX Requests

Another option for quickly setting up ShareX to work with the media server is to import the requests directly into ShareX, to do this navigate to: Destinations -> Custom Uploader Settings in the ShareX app, from there copy one of the ShareX requests found below and import it.

Note: You should edit the URL that the request goes to, as-well-as the API token that is used so the requests are sent to the correct media server with proper authorization.

Images

{
  "Version": "13.1.0",
  "Name": "ShareX Media Server - Images",
  "DestinationType": "ImageUploader",
  "RequestMethod": "POST",
  "RequestURL": "http://sharex-media-server.local/api/images",
  "Headers": {
    "Authorization": "Bearer <your API token goes here>",
    "Accept": "application/json"
  },
  "Body": "MultipartFormData",
  "FileFormName": "image",
  "URL": "$json:resource_url$"
}

Texts

{
  "Version": "13.1.0",
  "Name": "ShareX Media Server - Text & Files",
  "DestinationType": "TextUploader, FileUploader",
  "RequestMethod": "POST",
  "RequestURL": "http://sharex-media-server.local/api/texts",
  "Headers": {
    "Authorization": "Bearer <your API token goes here>",
    "Accept": "application/json"
  },
  "Body": "MultipartFormData",
  "FileFormName": "file",
  "URL": "$json:resource_url$"
}

Files

{
  "Version": "13.1.0",
  "Name": "Local - File uploads",
  "DestinationType": "FileUploader",
  "RequestMethod": "POST",
  "RequestURL": "http://sharex-media-server.local/api/files",
  "Headers": {
    "Authorization": "Bearer <your API token goes here>",
    "Accept": "application/json"
  },
  "Body": "MultipartFormData",
  "FileFormName": "file",
  "URL": "$json:resource_url$"
}

If you don't want to link to the resource information page after uploading files via ShareX, you can instead change "$json:resource_url$" to "$json:preview_url$", which will point to the preview URL instead.

URLs

{
  "Version": "13.1.0",
  "Name": "ShareX Media Server - URLs",
  "DestinationType": "URLShortener",
  "RequestMethod": "POST",
  "RequestURL": "http://sharex-media-server.local/api/urls",
  "Headers": {
    "Authorization": "Bearer <your API token goes here>",
    "Accept": "application/json"
  },
  "Body": "MultipartFormData",
  "Arguments": {
    "url": "$input$"
  },
  "URL": "$json:resource_url$"
}