Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-jfu

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-jfu

jQuery-File-Upload Hapi.js Middleware

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

hapi-jfu

jQuery-File-Upload Hapi.js Middleware

Dependency Status devDependency Status Build Status

jQuery-File-Upload Hapi.js Middleware. Based on the server code of jQuery-File-Upload

Installation:

    $ npm install hapi-jfu --save

Usage:

    server.route({
        method: 'POST',
        path: '/',
        config: {
            tags: ['api'],
            payload: {
                maxBytes: 209715200,
                output: 'stream',
                parse: false
            }
        },
        handler: function (request, reply) {

            const upload = request.server.plugins['storage/image'].jfu;

            upload.configure({
                uploadDir: './public/storage',
                uploadUrl: './storage',
                imageVersions: {
                    thumbnail: {
                        width: 80,
                        height: 80
                    }
                },
                server: {
                    request: request,
                    reply: reply
                }
            });

            upload.fileHandler();
        }
    });

Important : always need to configure payload in route with two parameter output and parse addition you should always pass request and reply parameter like above in configuration too .

On the frontend:

   <input id="fileupload" type="file" name="files[]" data-url="/upload" multiple>
   <script>$('#fileupload').fileupload({ dataType: 'json' })</script>

Other options and their default values:

{
    tmpDir: '/tmp',
    uploadDir: __dirname + '/public/uploads',
    uploadUrl: '/uploads',
    targetDir: uploadDir,
    targetUrl: uploadUrl,
    ssl: false,
    hostname: null, // in case your reverse proxy doesn't set Host header
                    // eg 'google.com'
    maxPostSize: 11000000000, // 11 GB
    minFileSize: 1,
    maxFileSize: 10000000000, // 10 GB
    acceptFileTypes: /.+/i,
    imageTypes: /\.(gif|jpe?g|png)$/i,
    imageVersions: {
        thumbnail: {
            width: 80,
            height: 80
        }
    },
    imageArgs: ['-auto-orient'],
    accessControl: {
        allowOrigin: '*',
        allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE'
    }
}

Forked from

jquery-file-upload-middleware

License

Copyright (c) 2017 Amirhossein Tavousi Released under the MIT license.

Keywords

FAQs

Package last updated on 19 Oct 2017

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