GithubHelp home page GithubHelp logo

beryju / imagik Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 1.0 2.55 MB

Pyazo, but fast. Small, compact file-server.

License: GNU General Public License v3.0

Dockerfile 1.03% Makefile 0.37% Go 64.67% JavaScript 31.57% HTML 1.74% CSS 0.62%

imagik's Introduction

Imagik

Pyazo, but fast. Imagik is a fast and lightweight fileserver, that

  • lets you access files by path
  • lets you access files by their Hash (MD5/SHA1/SHA2/SHA512)
  • lets you upload files with a very simple API

Running

Docker

Run the container like this:

docker run -p 8000:8000 -v "whatever directory you want to share":/share ghcr.io/beryju/imagik

Now you can access imagik on http://localhost:8000

Binary

Download a binary from GitHub and run it:

./imagik

Now you can access imagik on http://localhost:8000

Configuration

Example config file:

---
# secretKey: # Set this to the output of ./imagik generate-key
listen: localhost:8000
rootDir: ./root
authDriver: static # or null for no authentication or oidc
authStaticConfig:
  tokens:
    # Key is the username
    # Value is password hash generated by ./imagik hash-password
    test: "|2a|10|TanDKWLYO3LUS3SEyQGTz.L51M6cSJsLsK0wVEWl5lIK1XucTBQ8u" # test
# authOIDCConfig:
#   url: provider URL, which has a .well-known/openid-configuration
#   clientID: some-client-id
#   clientSecret: some-client-secret
#   redirect: URL which should be sent as redirect, /api/pub/oidc/callback
#   provider: Name of the login button

API

GET /<path>

Retrieve file stored at path.

GET /<path>?meta

Retrieve metadata for file stored at path.

PUT /<path>

Requires authentication

Accepts file uploads from the HTTP Request body, like using curl --data "@/path/to/filename". Returns a JSON object with all the hashes,

{
    "SHA128":"acd5aeeb3c8d1cf580a59bc3e125d249ecdd0eda",
    "SHA256":"e6b104c1420af07013b4378ddacaaa3938259422f07d5d47f7ea114cf9de80cf",
    "SHA512":"10c08e2134fb953f891c2a3655f3744c0321fa72aefdf6bff000eff0a3f7882a008fff477dfec9aa22519ad17fb0fafd602caf3773cb848a5250131fdf8559ab",
    "SHA512Short":"10c08e2134fb953f",
    "MD5":"7e97fa079923fcdb39eb39b480729f36"
}

GET /api/pub/health/liveness

Healthcheck endpoint, which returns a 201 Response as soon as imagik is running.

GET /api/pub/health/readiness

Healthcheck Readiness probe, which returns a 201 after the Hash Map has been populated, otherwise a 500.

GET /api/priv/list[?pathOffset=]

Requires authentication

List contents of a directory. Accepts a query parameter pathOffset, which is appended to the root directory.

POST /api/priv/move?to=&from=

Requires authentication

Move a file. Requires two query parameters, from and to, which are relative to the root directory.

POST /api/priv/upload

Requires authentication

Accepts Multipart-Form Encoded files and uploads them to the respective path from the form relative to the root directory.

Migrating from pyazo

If you didn't use Collections in pyazo, you can simple re-use the same Media folder for imagik, and all URLs will continue to work.

If you did use Collections, use the script below, to mirror your Collection Structure into Filesystem folders, which are used by imagik.

# Execute this in your pyazo installation directory
# docker-compose exec server ./manage.py shell
# Then paste the contents below into the shell.
# This will output the commands required to move the files
# into folders.
from pyazo.core.models import *
for c in Collection.objects.all():
    print(f"mkdir {c.name}")
    for o in c.object_set.all():
        rel_path = o.file.path.replace('/app/media/', '')
        print(f"mv {rel_path} {c.name}/{rel_path}")

ShareX

Use this custom uploader

{
  "Version": "13.4.0",
  "Name": "imagik",
  "DestinationType": "ImageUploader",
  "RequestMethod": "PUT",
  "RequestURL": "https://YOUR_IMAGIK_DOMAIN/$filename$",
  "Headers": {
    "Authorization": "Basic $base64:YOUR_USERNAME_HERE:YOUR_TOKEN_HERE$"
  },
  "Body": "Binary",
  "URL": "https://YOUR_IMAGIK_DOMAIN/$json:SHA512Short$"
}

imagik's People

Contributors

beryju avatar dependabot[bot] avatar lucaelin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

simhaonline

imagik's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.