Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

TheEngineerhub/nimg

Repository files navigation

nimg

nimg is a simple (~100 lines) self-hosted image/file hosting service written in nim. I created this initally to store my screenshots captured with Flameshot.

How to use

It's basically a RESTful service. There is no complex auth mechanism such as JWT or a database. You just set a token with environment variable to manage images. To use with Flameshot simply download this script, run after modifying the variables.

  • Get the file:

    • GET: http://localhost:8080/myimage.png
  • Upload a file:

    • POST: http://localhost:8080/u?token=super-secret
    • CURL: curl -F "file=@myimage.png" http://localhost:8080/u
    • file key is required.
  • Delete the file:

    • GET: http://localhost:8080/d/myimage.png?token=super-secret

  • token query string is always required for delete image.
  • If public upload is disabled, you must also use your token.

How to setup

Easiest way to install nimg is using docker-compose.

  • Download the compose file.
  • Edit environment variables.
  • Run:
$ docker-compose up
  • After that you should use reverse proxy to expose nimg to world. Such as Nginx Proxy Manager, it's easy to use, well known solution.

Build from source.

  • Install nim and nimble and command below should do the trick. Make sure to create .env.
$ export NIMG_ENVIRONMENT=development
$ nimble run

License

This repository is licensed under GPLv3 License.