Giter VIP home page Giter VIP logo

filedrop's Introduction

filedrop

Travis CI CodeCov Issues License

Lightweight file storage server with HTTP API.

Features

  • Painless configuration! You don't even have to rewrite requests on your reverse proxy!
  • Limits support! Link usage count, file size and storage time.
  • Embeddable! Can run as part of your application.

You can use filedrop either as a standalone server or as a part of your application. In former case you want to check filedropd subpackage, in later case just import filedrop package and pass config stucture to filedrop.New, returned object implements http.Handler so you can use it how you like.

Installation

This repository uses Go 1.11 modules. Things may work with old GOPATH approach but we don't support it so don't report cryptic compilation errors caused by wrong dependency version.

master branch contains code from latest (pre-)release. dev branch contains bleeding-edge code. You probably want to use one of tagged releases.

SQL drivers

filedrop uses SQL database as a meta-information storage so you need a SQL driver for it to use.

When building standalone server you may want to enable one of the supported SQL DBMS using build tags:

  • postgres for PostgreSQL
  • sqlite3 for SQLite3
  • mysql for MySQL

Note: No MS SQL Server support is planned. However if you would like to see it - PRs are welcome.

When using filedrop as a library you are given more freedom. Just make sure that you import driver you use.

Library

Just use github.com/foxcpp/filedrop as any other library. Documentation is here: godoc.org.

Standalone server

See fildropd subdirectory. To start server you need a configuration file. See example here. It should be pretty straightforward. Then just pass path to configuration file in command-line arguments.

filedropd /etc/filedropd.yml

systemd unit file is included for your convenience.

HTTP API

POST single file to any endpoint to save it. For example:

POST /filedrop
Content-Type: image/png
Content-Length: XXXX

You will get response with full file URL (endpoint used to POST + UUID), like this one:

http://example.com/filedrop/41a8f78c-ce06-11e8-b2ed-b083fe9824ac

You can add anything as last component to URL to give it human-understandable meaning:

http://example.com/filedrop/41a8f78c-ce06-11e8-b2ed-b083fe9824ac/amazing-screenshot.png

However you can't add more than one component:

http://example.com/filedrop/41a8f78c-ce06-11e8-b2ed-b083fe9824ac/invalid/in/filedrop

You can specify max-uses and store-time-secs to override default settings from server configuration (however you can't set value higher then configured).

POST /filedrop/screenshot.png?max-uses=5&store-secs=3600

Following request will store file screenshot.png for one hour (3600 seconds) and allow it to be downloaded not more than 10 times.

Note To get https scheme in URLs downstream server should set header X-HTTPS-Downstream to 1 (or you can also set HTTPSDownstream config option)

Authorization

When using filedrop as a library you can setup custom callbacks for access control.

See filedrop.AuthConfig documentation.

filedrop's People

Contributors

foxcpp avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

filedrop's Issues

Support range requests

This will allow browsers to resume interrupted downloads, for example.
Can be implemented using ServeFile from net/http.

Abstract away file I/O

Make filedrop hyper-scalable by allowing to use something different from OS interfaces for file access. Like, wrapper with replication.

Extend database support

  • Allow to build filedropd with drivers for DBs below (using build tags, probably).

  • Evaluate compatibility with MySQL

  • Evaluate compatibility with PostgreSQL

  • Bonus points: Include both databases in testing matrix on CI

Allow dynamic caching on middle-level

Basically, database should additionally include file add timestamp and return it in Last-Modified header.
Since files in filedrop storage are immutable we then just handle If-Modified-Since by comparing passed date with stored add timestamp.

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.