Giter Site home page Giter Site logo

rasata / droppy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from silverwind/droppy

1.0 2.0 0.0 9.26 MB

Self-hosted file storage

License: BSD 2-Clause "Simplified" License

Dockerfile 0.47% Makefile 1.22% JavaScript 71.05% CSS 14.09% HTML 12.97% Shell 0.20%

droppy's Introduction

droppy is a self-hosted file storage server with a web interface and capabilities to edit files and view media directly in the browser. It is particularly well-suited to be run on low-end hardware like the Raspberry Pi.

Features (try the demo)

  • Responsive, scalable HTML5 interface
  • Realtime updates of file system changes
  • Directory and Multi-File upload
  • Drag-and-Drop support
  • Clipboard support to create image/text files
  • Side-by-Side mode
  • Simple and fast Search
  • Shareable public download links
  • Zip download of directories
  • Powerful text editor with themes and broad language support
  • Image and video gallery with touch support
  • Audio player with seek support
  • Fullscreen support for editor and gallery
  • Supports installing to the homescreen
  • Docker images available for x86-64, ARMv6, ARMv7 and ARMv8

General Information

Two directories will be used, one for configuration and one for the actual files:

  • config: defaults to ~/.droppy/config, override with -c /some/dir
  • files: default ~/.droppy/files override with -f /some/dir

droppy maintains a in-memory representation of the files directory. If you're on slow storage and/or serving 100k or more files, the initial indexing on startup will likely take some time.

Installation

Local Installation ๐Ÿ“ฆ

With Node.js >= 8.0.0 installed, run:

$ sudo npm install -g --production droppy
$ droppy start -c /srv/droppy/config -f /srv/droppy/files

To update, run

$ sudo npm update -g --production droppy

To make droppy run in the background, you can use the --daemon option, thought it is adviced that you install it as a persistent service in you system. For Linux, see these guides:

Docker installation ๐Ÿณ

The following images are available:

To pull and run, use:

$ docker run --name droppy -p 127.0.0.1:8989:8989 silverwind/droppy

This method uses automatic volumes for /config and /files which can be overridden through -v /srv/droppy/config:/config and -v /srv/droppy/files:/files. If you're using existing files, it's advisable to use -e UID=1000 -e GID=1000 to get new files written with correct ownership.

To update a docker installation, run

$ docker pull silverwind/droppy
$ docker stop droppy && docker rm droppy
$ docker run --name droppy -p 127.0.0.1:8989:8989 silverwind/droppy

docker-compose

Alternatively, you can use the example docker-compose.yml:

$ curl -O https://raw.githubusercontent.com/silverwind/droppy/master/examples/docker-compose.yml
$ docker-compose up

This example docker-compose.yml uses the subdirectories config and files of the current working directory for storing data.

Configuration

By default, the server listens on all IPv4 and IPv6 interfaces on port 8989. On first startup, a prompt to create login data for the first account will appear. Once it's created, login credentials are enforced. Additional accounts can be created in the options interface or the command line. Configuration is done in config/config.json, which is created with these defaults:

{
  "listeners" : [
    {
      "host": ["0.0.0.0", "::"],
      "port": 8989,
      "protocol": "http"
    }
  ],
  "public": false,
  "timestamps": true,
  "linkLength": 5,
  "linkExtensions": false,
  "logLevel": 2,
  "maxFileSize": 0,
  "updateInterval": 1000,
  "pollingInterval": 0,
  "keepAlive": 20000,
  "allowFrame": false,
  "readOnly": false,
  "ignorePatterns": [],
  "watch": true
}

Options

  • listeners Array - Defines on which network interfaces, port and protocols the server will listen. See listener options below. listeners has no effect when droppy is used as a module. The default listens on HTTP port 8989 on all interfaces and protocols.
  • public boolean - When enabled, no user authentication is performed. Default: false.
  • timestamps boolean - When enabled, adds timestamps to log output. Default: true.
  • linkLength number - The amount of characters in a shared link. Default: 5.
  • linkExtensions boolean - Whether shared links should include the file extension. This can used to allow other software to make a guess on the content of the file without actually retrieving it.
  • logLevel number - Logging amount. 0 is no logging, 1 is errors, 2 is info (HTTP requests), 3 is debug (Websocket communication). Default: 2.
  • maxFileSize number - The maximum file size in bytes a user can upload in a single file.
  • updateInterval number - Interval in milliseconds in which a single client can receive update messages through changes in the file system. Default: 1000.
  • pollingInterval number - Interval in milliseconds in which the file system is polled for changes, which is likely necessary for files on external or network-mapped drives. This is CPU-intensive! Corresponds to chokidar's usePolling option. 0 disables polling. Default: 0.
  • keepAlive number - Interval in milliseconds in which the server sends keepalive message over the websocket, which may be necessary with proxies. 0 disables keepalive messages. . Default: 20000.
  • allowFrame boolean - Allow the page to be loaded into a <frame> or <iframe>. Default: false.
  • readOnly boolean - All served files will be treated as being read-only. Default: false.
  • compression boolean - Whether to serve brotli/gzip compressed static content. Default: true. Note that compression incurs no performance penalty because pre-compressed artifacts are included in the distribution. Default: true.
  • dev boolean - Enable developer mode, skipping resource minification and enabling live reload. Default: false.
  • ignorePatterns Array - Array of file name glob patterns to ignore when indexing files. Default: [].
  • watch boolean - Whether to watch the local file system for changes. Can improve performance when dealing with a large number of files. If watch is set to false, file system changed not done through droppy won't be detected. Default: true.

Listener Options

listeners defines on which network interfaces, ports and protocol(s) the server will listen. For example:

"listeners": [
  {
    "host": "::",
    "port": 80,
    "socket": "/tmp/droppy",
    "protocol": "http"
  },
  {
    "host": "0.0.0.0",
    "port": 443,
    "protocol": "https",
    "key": "~/certs/example.com.key",
    "cert": "~/certs/example.com.crt",
    "dhparam": "~/certs/example.com.dh",
    "hsts": 31536000
  }
]

The above configuration will result in:

  • HTTP listening on all IPv4 and IPv6 interfaces, port 80 and on the unix domain socket /tmp/droppy.
  • HTTPS listening on all IPv4 interfaces, port 443, with 1 year of HSTS duration, using the provided TLS files.

A listener object accepts these options:

  • host string/Array - Network interface(s) addresses to listen on. Required when port is given. Note that "::" will typically bind to both IPv4 and IPv6 on all addresses but a "0.0.0.0" address might be required if IPv6 is disabled.
  • port number/string/Array - Network port(s) to listen on. Required when host is given.
  • socket string/Array - Unix domain socket(s) to listen on.
  • protocol string - Protocol to use, http or https. Required.

For TLS the following additional options are available. Paths can be given relative to the configuration directory and ~ is resolved as expected.

  • cert string - Path to PEM-encoded TLS certificate file, which can include additional intermediate certificates concatenated after the main certificate. Required.
  • key string - Path to PEM-encoded TLS private key file. Required.
  • dhparam string - Path to PEM-encoded TLS Diffie-Hellman parameters file. If not provided, new 2048 bit parameters will generated on launch and saved for future use.
  • passphrase string - Passphrase for the TLS private key in case it is encrypted.
  • hsts number - Length of the HSTS header in seconds. Set to 0 to disable HSTS.

API

droppy can be used with express, see the express example.

droppy([options])

  • options Object: Options. Extends config.json. In addition to above listed options, configdir, filesdir and log are present on the API.

Returns a object {onRequest, setupWebSocket}.

Downloading from the command line

To download shared links with curl and wget to the correct filename:

$ curl -OJ url
$ wget --content-disposition url

Development

To start a live-reloading dev server:

$ git clone https://github.com/silverwind/droppy && cd droppy
$ npm i
$ node droppy start --dev

The Makefile has a few tasks for updating dependencies, pushing docker images, see the comment above for dependencies of those tasks.

ยฉ silverwind, distributed under BSD licence.

droppy's People

Contributors

aredridel avatar bl4de avatar cp1797 avatar gissehel avatar niieani avatar paulmillr avatar poorchop avatar pradyvr avatar r15ch13 avatar silverwind avatar tungel avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.