Giter Site home page Giter Site logo

krishnamraj / openpicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gauravtiwari5050/openpicker

0.0 0.0 0.0 2.99 MB

Open source and self hosted file picker for websites.

JavaScript 96.93% CoffeeScript 1.62% Shell 0.02% CSS 1.33% HTML 0.10%

openpicker's Introduction

OpenPicker

OpenPicker is an open source and self hosted file picker for your websites.

Installation

Deploy to Heroku

Deploy

Deploy to your server using npm

$ npm i -g openpicker

Start the server

$ openpicker

Add Javascript to your site

<script type="text/javascript">
      (function(window,document) {
        window.openpicker = {};
        var op = document.createElement('script'); op.type = 'text/javascript'; op.async = true;
        op.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '<ADD_YOUR_SERVER_HERE>/script/v1.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(op, s);
      })(window,document);
    </script>  

Pick single image

OpenPicker defaults to picking Image

    openpicker.getImage(function(openpickerResponse){
            $('#image').attr('src',openpickerResponse.file.url);
    });

Pick multiple images

OpenPicker defaults to picking Image

    openpicker.getImages(function(openpickerResponse){
            console.log(openpickerResponse.files);
    });

Pick single file of any type

OpenPicker defaults to picking Image

    openpicker.getFile(function(openpickerResponse){
            console.log(openpickerResponse.file);
    });

Pick files by mimetype (more details on options in the sections below)

OpenPicker defaults to picking Image

    openpicker.getFile(
        {
            mimetypes: 'application/pdf'
        }
        function(openpickerResponse){
            console.log(openpickerResponse.file);
        }
    );

Crop/Rotate Image before uploading

OpenPicker defaults to picking Image

    openpicker.getImage(
        {
            conversions:['crop','rotate'],
            cropRatio:16/9,
        }
        function(openpickerResponse){
            console.log(openpickerResponse.file);
        }
    );

Pick multiples files of any type

OpenPicker defaults to picking Image

    openpicker.getFiles(function(openpickerResponse){
            console.log(openpickerResponse.files);
    });

Server Configuration

OpenPicker expects a properties.conf file in the working directory. You can set the following options. You can set all the options in environment variables as well. Environment variables are given preference if set while reading a property.

FILESTORES=disk,s3 <comma seperated list, default: disk, only s3 and disk are supported as of now>

UPLPOAD_DIRECTORY=<full path to disk location where you want to save files, default is ./uploads>

MIN_SIZE=minimum file size in bytes

MAX_SIZE=maximum file size in bytes

S3_BUCKET = name of s3 bucket
AWS_ACCESS_KEY_ID= Aws access key if you have configured s3 as a filestore
AWS_SECRET_ACCESS_KEY = Aws secret access key
AWS_REGION = Aws Region of the bucket where you are uploading the files

Client Configuration

Available Fileupload Channels

- MY_COMPUTER  : Allows uploading file from current device

Client Options -

All these are optional , pass these while invoking openpicker.getFile()

- mimetypes : Comma seperated list of mimetypes (Ex: image/*,application/pdf)
- conversions : ['crop','rotate'] 
- cropRatio : Ex 16/9 - used while cropping the image
- channels : ['MY_COMPUTER'] - lets the client control channels to be used in the picker

OpenPicker uses a number of open source projects to work properly:

And of course OpenOpicker itself is open source with a public repository on GitHub.

Todos

  • Write Tests
  • Add more channels
  • Add more filestores

License

MIT

openpicker's People

Contributors

gauravtiwari5050 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.