n0vad3v / filebus

A simply upload fileserver for fun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filebus

A simply upload fileserver for fun

Build

Binary:

go build -o filebus .

Docker

docker build . -t n0vad3v/filebus:lastest

Usage

Filebus will by default listen on 0.0.0.0:3000, so using it with Docker is strongly recommended.

It supports two ways of uploading.

Upload method 1

You must fill in file and filepath variables

~ curl -F file=@main.py -F filepath=path/to/main.py http://localhost:3000/upload
{"md5":"5f3962dfab1b52e49f58b4fdaa22dc27","url":"http://filebus.nova.moe/path/to/main.py"}% 

Upload method 2

~ curl -F test/main.py=@main.py http://localhost:3000/upload
{"md5":"5f3962dfab1b52e49f58b4fdaa22dc27","url":"http://filebus.nova.moe/test/main.py"}%           

Download

~ curl http://localhost:3000/path/to/main.py
import json
import requests
import os
...

Delete file

➜  curl http://localhost:3000/delete/path/to/main.py
{"message":"File deleted successfully"}

➜  curl http://localhost:3000/delete/path/to/main.py
{"Error":"remove /data/path/to/main.py: no such file or directory"}

Deployment

Without DB

Filebus can be deployed without using any DB, and it's now a stateless service, you can create a docker-compose.yml file like this to quickly use Filebus:

version: '3'

services:

  filebus:
    image: n0vad3v/filebus:lastest
    restart: always
    environment:
      FILEBUS_URL: "https://filebus.nova.moe/"
    ports:
      - '0.0.0.0:3000:3000'
    volumes:
      - ./data:/data

With DB

First you need to spin up a working TiDB(or MySQL), create database called filebus, and initialize table called upload_logs with:

CREATE TABLE upload_logs (
    filename varchar(255),
    filepath varchar(255),
    filesize BIGINT,
    filehash varchar(255),
    uploader_ip varchar(255),
    uploaded_at DATETIME
);
CREATE TABLE delete_logs (
    filename varchar(255),
    filepath varchar(255),
    deleter_ip varchar(255),
    deleted_at DATETIME
);

docker-compose.yml example when using DB:

version: '3'

services:

  filebus:
    image: n0vad3v/filebus:latest
    restart: always
    environment:
      FILEBUS_URL: "https://filebus.nova.moe/"
      ENABLE_LOG: "TRUE"
      DB_HOST: "db"
      DB_USERNAME: "root"
      DB_PASSWORD: "password"
      DB_DBNAME: "filebus"
    ports:
      - '0.0.0.0:3000:3000'
    volumes:
      - ./data:/data

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: 'filebus'
      MYSQL_USER: 'user'
      MYSQL_PASSWORD: 'password'
      MYSQL_ROOT_PASSWORD: 'password'
    ports:
      - '0.0.0.0:3306:3306'
    volumes:
      - ./db_data:/var/lib/mysql

License

Filebus is under the GPLv3. See the LICENSE file for details.

About

A simply upload fileserver for fun

License:GNU General Public License v3.0


Languages

Language:Go 93.1%Language:Dockerfile 6.9%