~williewillus/filite

Heavily customized fork of https://github.com/raftario/filite
Disable unused actix web features
Declare time feature for tokio
Clippy lint

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~williewillus/filite
read/write
git@git.sr.ht:~williewillus/filite

You can also use your local clone with git send-email.

#filite

#~williewillus note

This project was originally forked from the legacy 0.3.0 branch of https://github.com/raftario/filite . It has been heavily customized for the author's own use cases. Those seeking an openly developed project should use the upstream project instead.

#~williewillus Things to do

  • Slim/update dependencies
  • Vendor any JS/CSS deps
  • Nicer display for paste showing (codemirror, etc.)
  • Public vs private uploads
  • User management (e.g. htpasswd files?)

A simple, light and standalone pastebin, URL shortener and file-sharing service that hosts files, redirects links and stores texts.

#Table of Contents

#Features

#What it is

  • Easy to use. Installation and set-up take less than a minute and a built-in web UI is provided.
  • Standalone. No external dependencies required, everything that is needed is packed into the binary.
  • Light and fast. The Rust web framework Actix is used under the hood, providing great speed with a minimal footprint.

#What it is not

  • A tracking tool. No stats are stored to increase speed, reduce resource usage and maintain simplicity, if this is what you are looking for filite is not for you.

#Installation

  1. Download and build from source.
  2. Run filite passwd to set the initial password
  3. Run filite. The program will create its state in the current working directory.

That's it!

#Usage

When asked for a login, use whatever username you want and the password you provided during setup. Details for programmatic usage are provided in the dedicated section.

#Config

# Port to listen on
port = 8080

# Highlight.js configuration
[highlight]
# Theme to use
theme = "github"
# Additional languages to include
languages = ["rust"]

#Client tools

#ShareX

  • <AUTHORIZATION> is the result of encoding <USERNAME>:<PASSWORD> to base64
    • <USERNAME> is an arbitrary username, it doesn't matter
    • <PASSWORD> is the password entered during setup
  • <ADDRESS> is the root address where the filite is running, for instance http://localhost:8080 or https://filite.raphaeltheriault.com
#File
{
  "Version": "13.0.1",
  "Name": "filite (file)",
  "DestinationType": "ImageUploader, FileUploader",
  "RequestMethod": "POST",
  "RequestURL": "<ADDRESS>/f",
  "Headers": {
    "Authorization": "Basic <AUTORIZATION>"
  },
  "Body": "MultipartFormData",
  "FileFormName": "file",
  "URL": "<ADDRESS>/$response$"
}
{
  "Version": "13.0.1",
  "Name": "filite (link)",
  "DestinationType": "URLShortener",
  "RequestMethod": "POST",
  "RequestURL": "<ADDRESS>/l",
  "Headers": {
    "Authorization": "Basic <AUTORIZATION>"
  },
  "Body": "JSON",
  "Data": "{\"forward\":\"$input$\"}",
  "URL": "<ADDRESS>/l/$response$"
}
#Text

You can remove the prompt and always enable or disable syntax highlighting by replacing $prompt:Highlight|false$ with true or false.

{
  "Version": "13.0.1",
  "Name": "filite (text)",
  "DestinationType": "TextUploader",
  "RequestMethod": "POST",
  "RequestURL": "<ADDRESS>/t",
  "Headers": {
    "Authorization": "Basic <AUTORIZATION>"
  },
  "Body": "JSON",
  "Data": "{\"contents\":\"$input$\",\"highlight\":$prompt:Highlight|false$}",
  "URL": "<ADDRESS>/t/$response$"
}

#Reverse proxy

  • <DOMAIN> is the domain the requests will be coming from, for instance filite.raphaeltheriault.com
  • <PORT> is the port on which filite is listening

Upload limits are set to 10M as an example

#NGINX

server {
  listen 80;
  listen [::]:80;

  server_name <DOMAIN>;

  location / {
    proxy_pass http://localhost:<PORT>;

    location /f {
      client_max_body_size 10M;
    }
  }
}

#Apache

<VirtualHost *:80>
  ServerName <DOMAIN>

  ProxyPreserveHost On
  ProxyPass / http://localhost:<PORT>/
  ProxyPassReverse / http://localhost:<PORT>/

  <Location "/f">
    LimitRequestBody 10000000
  </Location>
</VirtualHost>

#Programmatic usage

All requests that require authentication use HTTP Basic Auth (without taking the username into account).

#Creating new entries

There are two ways to create new entries, PUT or POST requests. For files and texts, PUT requests must refer to an existing ID. For links, a potentially-nonexistent ID is ok. POST will automatically generate an ID. Both methods require authentication.

#Files
  • PUT /f/{id}
  • POST /f

Files are sent as multipart/form-data. The field name isn't important but the file name needs to be included. Only one file is treated.

  • PUT /l/{id}
  • POST /l

Links are sent as application/json according to the following schema.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Link",
  "type": "object",
  "properties": {
    "forward": {
      "description": "URL this link forwards to",
      "type": "string"
    }
  }
}
#Texts
  • PUT /t/{id}
  • POST /t

Texts are sent as application/json according to the following schema.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Text",
  "type": "object",
  "properties": {
    "contents": {
      "description": "Text contents",
      "type": "string"
    },
    "highlight": {
      "description": "Whether to enable code highlighting or not for that text",
      "type": "boolean"
    }
  }
}

#Deleting entries

It's possible to delete any entry with an authenticated request.

  • DELETE /f
  • DELETE /l
  • DELETE /t

#Contributing

#Requirements

  • The Rust toolchain (MSRV 1.51)

#License

filite is licensed under the MIT License.