New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@leapit/storage

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leapit/storage

Storage

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

Storage

Usage

npm install @leapit/storage

Config your storage like this

Example

    storage: {
        dir: './storage',
        upload: {
            port: 8080,
            form: {
                //uploadDir: './storage',
                keepExtensions: true,
                multiples: true,
                maxFieldsSize: 2 * 1024 * 1024 // npm issue,not work
            },
            file: {
                ext: ['.gif', '.jpg', '.png'], // '*' for all type file
                maxsize: 2 * 1024 * 1024
            },
            image: {
                thumb: true, //need install graphicsmagick/imagemagick on server (https://github.com/aheckmann/gm)
                prefix: 'thumb_',
                resize: [150, 150, '!'], //[150,150,''] 按照比例缩略
                overwrite: false
            }
        },
        restapi: {
            port: 9090,
        },
        persistence: {
            url: 'mongodb://localhost:27017/storage',
            mongo: {},
            files: 'files',
            logs:'logs'
        }
    }

Custom permission like this

var authApi = {};

authApi = {
    // Accepts the connection if the token are valid
    authenticate: function authenticate(token, callback) {
        var clientid = '';
        var userid = '';
        console.log(':::::::::: checking token ::::::::::');
        console.log(token);

        var authorized = (token === 'user.token.here');
        if (authorized) {
            clientid = 'clientid';
            userid = 'userid';
            callback(null, clientid, userid);
        } else {
            callback(new Error('token error.'), clientid, userid);
        }
    }

};

module.exports = authApi;

Usage

###1. Embed in your app(Recommend)

    var storage = require('@leapit/storage');
    var config = require('./storage.config');
    var permission = require('./storage.permission');
    storage(config, permission);

Example with express https://github.com/leapit/storage/wiki/Embed-in-express-js

###2. Stand alone

https://github.com/leapit/storage/wiki/Stand-alone

Start your app

When your server started(e.g run npm start),the terminal will show

Storage upload server run at 8080
Storage download server run at 9090

Example for upload a file

<form action="http://localhost:8080/?token=user.token.here" enctype="multipart/form-data" method="post">
<input type="text" name="container" value="my-path">
<input type="text" name="tag" value="tag1">
<input type="text" name="tag" value="tag2">
<input type="text" name="description" value="miaosu">
<br />
<input type="text" name="sharelevel" value="1">
<input type="text" name="shareto" value="VJZnd0PFl">
<input type="text" name="shareto" value="E1QwuAPKe">
<br><input type="file" name="upload" multiple="multiple">
<br><input type="submit" value="Upload">
</form>

More refer to wiki

Keywords

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc