Skip to content

NicolasGB/filecrab

Repository files navigation

logo

⚡ A blazingly fast file and text sharing service ⚡

Build Rust License AUR Version

What's Filecrab?

File and text sharing application, built on top of MinIO and SurrealDB and powered by Rust. You can host your own instance, simply need a MinIO bucket and a SurrealDB instance.

A useful CLI will allow you to upload files and text to an instance.

Features

  • File sharing.
  • File expiration.
  • One-time text sharing.
  • Files optionally encrypted.
  • Text always encrypted.
  • Server-side cleanup of expired files and text based on user defined interval.
  • Memorable words list for IDs, inspired by Magic Wormhole.
  • Server can be run in distant or embedded mode.
  • The cli can manage multiple instances of filecrab.
  • A web front end to download files directly from the web.

Security

All data is encrypted through the age library. Encryption is done client side, in the CLI tool, this allows us to stream files directly to the storage without the need of reading it in memory on the server. The password is never sent to the server.

Table of Contents

Server

Local

Configuration

The server can be configured with environment variables, see the example.

Running

You can run the application with all required services using the following commands:

# Build the filecrab Docker image.
just build
# Or if you want to build in release mode.
# just build release

# Run the multi-container application.
just up

Important

You will need to have just installed to run the commands.

Note

The server will be available at http://localhost:8080.

Docker

Filecrab is also available as a Docker Image.

There are two types of images available:

  • nicolasgoutte/filecrab:<TAG> - Is the main image that runs the server and will connect to surrealdb via a websocket.
  • nicolasgoutte/filecrab:rocksdb-<TAG> - Is an alternative image that runs the server and has an embedded rocksdb engine, meaning that there is no need to deploy a surrealdb, but data is written to the disk.

Note

For more information on surrealdb, please refer to the documentation.

Chose the image that best fits your needs.

Deployment

To deploy the server, you need to set up the following services:

  • MinIO - To store the files.
  • SurrealDB - To store the metadata. (Not needed if running the rocksdb image).
  • Traefik - To handle the reverse proxy. (Or any alternative to expose the server to the internet).
  • Filecrab - The server itself.

Server configuration

Please refer to the example for the server configuration.

Web

web_view

You can deploy a front end fully made in Rust with dioxus. It will allow users to download files directly from the web. Useful for those not familiar with CLI tools.

Deployment

You simply need to download the docker image.

Warning

For the front end to be able to communicate to the backend you MUST deploy it under the same origin.

Ex. Frontend: https://my.filecrab.instance.com then your backend should be under: https://my.filecrab.instance.com/api. Make sure when exposing /api has priority over the frontend.

CLI

Installation

Arch Linux

Use an AUR helper to install the package:

Here is an example with paru

paru -S filecrab-bin

From source

You can install the CLI with the following command:

cargo install --path filecrab-cli

From GitHub

  • Go to the releases page and download the latest version.
  • Place the binary in somewhere in your $PATH so it can be executed from anywhere.

Warning

Remember to make the binary executable with chmod +x filecrab.

Usage

Set up

The CLI needs to be configured with at least one instance of filecrab. You can either init de config via a command or on the first run, you will be asked to provide this information. Follow the instructions to set up the CLI.

filecrab init

You will be asked to set a name for the instance and then URL and API key.

Note

The path to the configuration file is ~/.config/filecrab/config.toml. You can edit it manually if needed.

Multi Instances

You can manage multiple instances of filecrab and switch easily between them. Each instance must have a name and cannot be the same as an existent one.

Add

Allows you to add a new instance of filecrab.

filecrab add
Remove

Allows you to remove an existing instance of filecrab.

filecrab remove
Switch

Allows you to switch the active instance used by the cli.

filecrab switch

Files

Upload

You can upload a file without encryption using the following command:

filecrab upload <PATH>

If you want to encrypt the file, you can use the --pwd flag:

filecrab upload <PATH> --pwd <PASSWORD>
Download

To download a file, you can use the following command, replacing <ID> with the memorable_word_list of the file:

filecrab download <ID>

If the file is encrypted, you need to provide the password with the --pwd flag:

filecrab download <ID> --pwd <PASSWORD>

Note

By the file will be saved in the current directory with the original name. There is an optional flag --path to specify the path where the file will be saved.

filecrab download <ID> --path <PATH>

Or if the file is encrypted:

filecrab download <ID> --pwd <PASSWORD> --path <PATH>

Text

Paste

You can paste text to the server using the following command:

filecrab paste [CONTENT] --pwd <PASSWORD>

The password is mandatory as text is always encrypted in filecrab.

Note

The content can be provided as an argument or piped to the command.

To pipe the content, you can use the following command:

echo "Hello, World!" | filecrab paste --pwd <PASSWORD>

Any text piped will be read by filecrab.

Copy

To copy a text, you can use the following command, replacing <ID> with the memorable_word_list of the text:

filecrab copy <ID> <PWD>

Filecrab will by default copy to the clipboard the content of the text. But you can output the content to the terminal using the --output flag:

filecrab copy <ID> <PWD> --output

Help

All the commands have a help message that can be accessed with the --help flag:

filecrab --help

License

This project is licensed under the MIT license.