Code Monkey home page Code Monkey logo

filebin's Introduction

About

Filebin is a very simple web application that supports multifile upload and large file uploads. The upload feature is based on XmlHttpRequest. Clients are required to use browsers with File API support to be able to upload files.

Requirements

Some Python modules, MongoDB and Apache, Nginx+uwsgi and zip

For ubuntu: sudo apt-get install mongodb-server python-pymongo python-jinja2 python-flask python-werkzeug python-magic python-pythonmagick python-pyexiv2 uwsgi uwsgi-plugin-python zip

Additional configuration

Logrotate

/var/log/app/filebin/*.log {
  daily
  missingok
  rotate 90
  compress
  notifempty
  copytruncate
  create 640 www-data www-data
  sharedscripts
}

Nginx

server {
    listen   80;
    listen   [::]:80;

    access_log /var/log/nginx/filebin.net-access.log;
    server_name www.filebin.net;
    rewrite ^(.*) http://filebin.net$1 permanent;
}

server {
    listen   80;
    listen   [::]:80;

    access_log /var/log/nginx/filebin.net-access.log;

    # Please note that the root path should point to the directory where
    # the tags and files are being stored.
    root /srv/www/filebin/files/;

    index index.html index.htm;
    server_name filebin.net;

    # http://aspyct.org/blog/2012/08/20/setting-up-http-cache-and-gzip-with-nginx/
    gzip on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    server_tokens off;

    client_max_body_size       0;

    # For historical compability
    rewrite ^/([^/]+)/file/(.*) http://filebin.net/$1/$2 permanent;
    rewrite ^/admin/([^/]+)/([^/]+)/(.+) http://filebin.net/$1?v=configuration&key=$2 permanent;

    location /static {
        root /srv/www/filebin/;
    }

    location /thumbnails {
        root /srv/www/filebin/;
    }

    location /uploader {
        limit_except POST          { deny all; }

        client_body_temp_path      /srv/www/filebin/temp;
        client_body_in_file_only   clean;
        client_body_buffer_size    128K;

        proxy_pass_request_headers on;
        proxy_set_header           host        $host;
        proxy_set_header           x-tempfile  $request_body_file;
        proxy_set_header           x-filename  $http_x_filename;
        proxy_set_header           x-tag       $http_x_tag;
        proxy_set_header           x-size      $http_x_size;
        proxy_set_header           x-useragent $http_user_agent;
        proxy_set_header           x-checksum  $http_x_checksum;
        proxy_set_header           x-client    $remote_addr;
        proxy_set_body             off;
        proxy_redirect             off;

        # A high timeout is necessary to let the backend calculate the
        # checksum and move the (potentially large) file into place.
        proxy_read_timeout         3600;
        proxy_pass                 http://filebin.net/callback-upload;
    }

    location /overview {
        try_files $uri @filebin;
        allow   1.2.3.4;
        deny    all;
    }

    location /monitor {
        try_files $uri @filebin;
        allow   1.2.3.4;
        deny    all;
    }

    # Restrict world access to the maintenance uri
    location /maintenance {
        try_files $uri @filebin;
        allow   1.2.3.4;
        deny    all;
    }

    # Try to serve the file if the file exists, or let the web application
    # handle the request.
    location / { try_files $uri @filebin; }
    location @filebin {
        include uwsgi_params;
        uwsgi_param                REMOTE_ADDR $remote_addr;
        uwsgi_param                REMOTE_PORT $remote_port;
        uwsgi_read_timeout         6000;
        uwsgi_send_timeout         6000;

        # Disable max temp file size to allow huge archives
        uwsgi_max_temp_file_size   0;

        client_body_buffer_size    128k;
        uwsgi_pass unix:/run/shm/filebin.sock;
    }
}

Uwsgi (filebin.yaml)

uwsgi:
    uid: nginx
    gid: nginx
    socket: /run/shm/filebin.sock
    post-buffering: 0
    plugins: http,python
    processes: 15
    module: filebin
    callable: app
    chdir: /srv/www/filebin/app/
    no-orphans: true
    log-date: true
    master: true

Periodic tasks

http://filebin.net/maintenance will generate thumbnails and remove expired tags for you. Configure a cron job to GET this URL periodically to ensure that these tasks are being executed. It will return 200 if the tasks are executed successfully.

License

The filebin web application is licensed under GNU Affero General Public License http://www.gnu.org/licenses/agpl.html. Some of the modules used (flask, geoip, jinja, werkzeug, etc) are or may be under other licenses.

TODO

  • Statistics in the admin interface.
  • Proper MD5 checksumming during upload.
  • Client side error handling.
  • Fix the blocking feature which is broken now, or even add a remove by request feature to let users knowing tags remove them.

filebin's People

Contributors

espebra avatar haraldweber avatar torhve avatar

Watchers

James Cloos 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.