Giter Site home page Giter Site logo

blueimp-file-upload-expressjs's Introduction

Blueimp file upload for Express js

Build Status ![Gitter](https://badges.gitter.im/Join Chat.svg)

NPM

* * This project is no longer under active maintenance, if anyone is interested to manage this, please reach out to me. * *

A simple express module for integrating the jQuery File Upload frontend plugin.

Fullstack Demo | Tutorial on my blog

v 0.4.0 Released!

Contents

Main features in v0.4.0

  1. Upgrade lwip to v0.0.6

It means that we can upload and proccess GIF images now.

  1. More NodeJs friendly callback API

Using function(err,data) instead of function(data,err)

Notices on upgrading v0.3.x to v0.4.0

In order to make v0.4.0 to work properly, we need to change the uploader instance's callback function correspondingly as mentioned above.

From v0.3.x style,

uploader.get(req, res, function (obj) {
    res.send(JSON.stringify(obj)); 
});

To v0.4.0 style,

uploader.get(req, res, function (err,obj) {
    if(!err){
        res.send(JSON.stringify(obj));
    }
});

Similar rule that applies to the callback functions of uploader.post and uploader.delete.

History

The code was forked from a sample backend code from the plugin's repo. Adaptations were made to show how to use this plugin with the popular Express Node.js framework.

Although this code was initially meant for educational purposes, enhancements were made. Users can additionally:

  • upgrade lwip to version 0.0.6 to support gif images (New at v0.4.0)
  • choose the destination filesystem, local or cloud-based Amazon S3,
  • create thumbnail without heavy external dependencies using lwip,
  • setup server-side rules by configuration,
  • modify the code against a test harness.

Installation

Setup an Express project and install the package.

$ npm install blueimp-file-upload-expressjs

Beginners can follow the tutorial for detailed instructions.

Configuration

options = {
    tmpDir: __dirname + '/tmp', // tmp dir to upload files to
    uploadDir: __dirname + '/public/files', // actual location of the file
    uploadUrl: '/files/', // end point for delete route 
    maxPostSize: 11000000000, // 11 GB
    minFileSize: 1,
    maxFileSize: 10000000000, // 10 GB
    acceptFileTypes: /.+/i,
    inlineFileTypes: /\.(gif|jpe?g|png)/i,
    imageTypes:  /\.(gif|jpe?g|png)/i,
    copyImgAsThumb : true, // required
    imageVersions :{
        maxWidth : 200,
        maxHeight : 200
    },
    accessControl: {
        allowOrigin: '*',
        allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',
        allowHeaders: 'Content-Type, Content-Range, Content-Disposition'
    },
    storage : {
        type : 'local', // local or aws
        aws : {
            accessKeyId :  'xxxxxxxxxxxxxxxxx', // required if aws
            secretAccessKey : 'xxxxxxxxxxxxxxxxxxxxxxx', // required if aws
            region : 'us-west-2', //make sure you know the region, else leave this option out
            bucketName : 'xxxxxxxxx' // required if aws
        }
    }
};

Usage with options

(refer tutorial)

// config the uploader
var options = {
    tmpDir:  __dirname + '/../public/uploaded/tmp',
    uploadDir: __dirname + '/../public/uploaded/files',
    uploadUrl:  '/uploaded/files/',
    maxPostSize: 11000000000, // 11 GB
    minFileSize:  1,
    maxFileSize:  10000000000, // 10 GB
    acceptFileTypes:  /.+/i,
    // Files not matched by this regular expression force a download dialog,
    // to prevent executing any scripts in the context of the service domain:
    inlineFileTypes:  /\.(gif|jpe?g|png)/i,
    imageTypes:  /\.(gif|jpe?g|png)/i,
    copyImgAsThumb : true, // required
    imageVersions :{
        maxWidth : 200,
        maxHeight : 200
    },
    accessControl: {
        allowOrigin: '*',
        allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',
        allowHeaders: 'Content-Type, Content-Range, Content-Disposition'
    },
    storage : {
        type : 'aws',
        aws : {
            accessKeyId :  'xxxxxxxxxxxxxxxxx',
            secretAccessKey : 'xxxxxxxxxxxxxxxxx',
            region : 'us-east-1',//make sure you know the region, else leave this option out
            bucketName : 'xxxxxxxxxxxxxxxxx'
        }
    }
};

// init the uploader
var uploader = require('blueimp-file-upload-expressjs')(options);


module.exports = function (router) {
    router.get('/upload', function(req, res) {
      uploader.get(req, res, function (err,obj) {
            if(!err){
                res.send(JSON.stringify(obj));
            }
      });
      
    });

    router.post('/upload', function(req, res) {
      uploader.post(req, res, function (error,obj, redirect) {
          if(!error)
          {
            res.send(JSON.stringify(obj)); 
          }
      });
      
    });
    
    // the path SHOULD match options.uploadUrl
    router.delete('/uploaded/files/:name', function(req, res) {
      uploader.delete(req, res, function (err,obj) {
            res.Json({error:err}); 
      });
      
    });
    return router;
}

SSL Support

Set the useSSL option to true to use the package with an HTTPS server.

var express = require('express')
var fs = require('fs')
var https = require('https');

var app = express()

// config the uploader
var options = {
    ...
    useSSL: true
    ...
};

// init the uploader
var uploader = require('blueimp-file-upload-expressjs')(options);

app.get('/upload', function(req, res) {
    uploader.get(req, res, function (err,obj) {
    if(!err)
        res.send(JSON.stringify(obj)); 
})
    .post('/upload', // ...
    .delete('/uploaded/files/:name', // ...

// create the HTTPS server
var app_key = fs.readFileSync('key.pem');
var app_cert = fs.readFileSync('cert.pem');

https.createServer({key: app_key, cert: app_cert}, app).listen(443);

Multiple thumbnails

To generate multiple thumbnails while uploading

var options = {
  tmpDir: __dirname + '/../public/uploaded/tmp',
  uploadDir: __dirname + '/../public/uploaded/files',
  uploadUrl: '/uploaded/files/',
  copyImgAsThumb: true, // required
  imageVersions: {
    maxWidth: 200,
    maxHeight: 200
  },
  storage: {
    type: 'local'
  }
};

copyImgAsThumb needs to be set to true. imageVersions, maxWidth and maxHeight will by default create a thumbnail folder and place the specified width/height thumbnail in it.

Optionally, you can omit the maxHeight. In this case, it will be resize proportionally to the specified width.

imageVersions: {
    maxWidth: 200
  },

also

imageVersions: {
    maxWidth: 200,
    maxHeight : 'auto'
  },

PS : auto value works only with height.

You can also specify multiple thumbnail generations like

var options = {
  tmpDir: __dirname + '/../public/uploaded/tmp',
  uploadDir: __dirname + '/../public/uploaded/files',
  uploadUrl: '/uploaded/files/',
  copyImgAsThumb: true,
  imageVersions: {
    maxWidth: 200,
    maxHeight: 'auto',
    "large" : {
        width : 600,
        height : 600
    },
    "medium" : {
        width : 300,
        height : 300
    },
    "small" : {
        width : 150,
        height : 150
    }
  },
  storage: {
    type: 'local'
  }
};

Get Form Fields along with Upload

Form fields will come as a part of a JSON object of fileInfo(like title/description). If not specified then will return empty object. [PR42]

Refer to : How to submit additional form data to send additional form data from the client.

Tests

Unit tests can be run with Jasmine using npm test or this command:

$ jasmine-node specs/

Manual end to end tests can be done with this full project. Change the require() path of uploadManager.js to link it this cloned repository.

Contributions

Changes and improvements are welcome! Feel free to fork and open a pull request.

To Do

  • Make Configuration documentation clearer and shorter,
  • Refactor code to build tests and provide generic transports as in winston,
  • Write end to end tests with WebdriverIO,
  • Provide a basic image processing pipeline (resizing, croping, filter effects),
  • Fix AWS thubnail issue,
  • Provide access to other cloud-based services like Microsoft Azure.

Done

  • Fix Thumbnail creation when uploading images with a more 'feasible' approach,
  • Amazon S3 integration,
  • SSL Support.

License

blueimp-file-upload-expressjs is licensed under the MIT licence.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

blueimp-file-upload-expressjs's People

Contributors

arvindr21 avatar cdallagnola avatar gitter-badger avatar itorets avatar linkesch avatar mamboer avatar maroshii avatar mycaule avatar simison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blueimp-file-upload-expressjs's Issues

Upload to S3, but request aborted.

I use this module upload file to s3. but when uploading, it report aborted.

form.on('aborted', function () {
            console.log('I\'m aborted');
   tmpFiles.forEach(function (file) {
                fs.unlink(file);
   });
});

But I can't catch any available info, just knew it maybe cause by formidable req.on('aborted').
Is there any other way to upload to S3?

macOS npm install blueimp-file-upload-expressjs erro

when i install blueimp-file-upload-expressjs, i found a mount of erros, I do not know how to fix it.

I was already install python 2.7 , xcode Command Line Tools, gcc and make all ok.

[email protected] install /Users/doudouhe/WebstormProjects/svn/aladdin_proj/trunk/cpc/node_modules/blueimp-file-upload-expressjs/node_modules/lwip
node-gyp rebuild

2017-04-07 15:36:45.683 xcodebuild[64131:33653799] [MT] PluginLoading: Required plug-in compatibility UUID E0A62D1F-3C18-4D74-BFE5-A4167D643966 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/OMQuickHelp.xcplugin' not present in DVTPlugInCompatibilityUUIDs
CXX(target) Release/obj.target/lwip_decoder/src/decoder/init.o
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:120:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:115:25: note: previous definition is here
NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) {
^
../../nan/nan.h:207:68: error: too many arguments to function call, expected at
most 2, have 4
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:4832:3: note: 'New' declared
here
static Local New(
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:262:32: warning: 'CompileUnbound' is deprecated
[-Wdeprecated-declarations]
return v8::ScriptCompiler::CompileUnbound(
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:1334:45: note:
'CompileUnbound' has been explicitly marked deprecated here
Local CompileUnbound(
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:271:32: warning: 'CompileUnbound' is deprecated
[-Wdeprecated-declarations]
return v8::ScriptCompiler::CompileUnbound(
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:1334:45: note:
'CompileUnbound' has been explicitly marked deprecated here
Local CompileUnbound(
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:277:31: warning: 'New' is deprecated [-Wdeprecated-declarations]
return v8::BooleanObject::New(value).Asv8::BooleanObject();
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:4007:56: note: 'New' has been
explicitly marked deprecated here
V8_DEPRECATED("Pass an isolate", static Local New(bool value));
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:289:3: error: redefinition of 'NanNew'
NanNew<v8::StringObject, v8::Handlev8::String >(
^
../../nan/nan.h:282:3: note: previous definition is here
NanNew<v8::StringObject, v8::Localv8::String >(
^
../../nan/nan.h:307:36: error: redefinition of 'NanNew'
NAN_INLINE v8::Localv8::RegExp NanNew(
^
../../nan/nan.h:301:36: note: previous definition is here
NAN_INLINE v8::Localv8::RegExp NanNew(
^
../../nan/nan.h:319:36: error: redefinition of 'NanNew'
NAN_INLINE v8::Localv8::RegExp NanNew(
^
../../nan/nan.h:313:36: note: previous definition is here
NAN_INLINE v8::Localv8::RegExp NanNew(
^
../../nan/nan.h:327:42: warning: 'ToUint32' is deprecated
[-Wdeprecated-declarations]
v8::Isolate::GetCurrent(), val)->ToUint32();
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:8196:22: note: 'ToUint32' has
been explicitly marked deprecated here
Local Value::ToUint32() const {
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:333:42: warning: 'ToUint32' is deprecated
[-Wdeprecated-declarations]
v8::Isolate::GetCurrent(), val)->ToUint32();
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:8196:22: note: 'ToUint32' has
been explicitly marked deprecated here
Local Value::ToUint32() const {
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:338:60: warning: 'ToInt32' is deprecated
[-Wdeprecated-declarations]
return v8::Int32::New(v8::Isolate::GetCurrent(), val)->ToInt32();
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:8202:21: note: 'ToInt32' has
been explicitly marked deprecated here
Local Value::ToInt32() const {
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:343:60: warning: 'ToInt32' is deprecated
[-Wdeprecated-declarations]
return v8::Int32::New(v8::Isolate::GetCurrent(), val)->ToInt32();
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:8202:21: note: 'ToInt32' has
been explicitly marked deprecated here
Local Value::ToInt32() const {
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:388:24: warning: 'NewFromOneByte' is deprecated
[-Wdeprecated-declarations]
return v8::String::NewFromOneByte(
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:2334:21: note:
'NewFromOneByte' has been explicitly marked deprecated here
Local NewFromOneByte(Isolate* isolate, const uint8_t* data,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:399:24: warning: 'NewFromOneByte' is deprecated
[-Wdeprecated-declarations]
return v8::String::NewFromOneByte(
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:2334:21: note:
'NewFromOneByte' has been explicitly marked deprecated here
Local NewFromOneByte(Isolate* isolate, const uint8_t* data,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:408:24: warning: 'NewFromOneByte' is deprecated
[-Wdeprecated-declarations]
return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), arg);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:2334:21: note:
'NewFromOneByte' has been explicitly marked deprecated here
Local NewFromOneByte(Isolate* isolate, const uint8_t* data,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:414:24: warning: 'NewFromOneByte' is deprecated
[-Wdeprecated-declarations]
return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), arg);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:2334:21: note:
'NewFromOneByte' has been explicitly marked deprecated here
Local NewFromOneByte(Isolate* isolate, const uint8_t* data,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:500:24: warning: 'NewExternal' is deprecated
[-Wdeprecated-declarations]
return v8::String::NewExternal(v8::Isolate::GetCurrent(), resource);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:2372:38: note: 'NewExternal'
has been explicitly marked deprecated here
Local NewExternal(
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:531:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Primitive]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:536:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Primitive]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:541:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Boolean]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:546:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Boolean]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:590:20: error: no type named 'GCEpilogueCallback' in
'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback
~~~~~~~~~~~~~^
../../nan/nan.h:596:20: error: no type named 'GCEpilogueCallback' in
'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback) {
~~~~~~~~~~~~~^
../../nan/nan.h:601:20: error: no type named 'GCPrologueCallback' in
'v8::Isolate'
v8::Isolate::GCPrologueCallback callback
~~~~~~~~~~~~~^
../../nan/nan.h:607:20: error: no type named 'GCPrologueCallback' in
'v8::Isolate'
v8::Isolate::GCPrologueCallback callback) {
~~~~~~~~~~~~~^
../../nan/nan.h:778:13: error: no member named 'smalloc' in namespace 'node'
, node::smalloc::FreeCallback callback
~~~~~~^
../../nan/nan.h:789:12: error: no matching function for call to 'New'
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^~~~~~~~~~~~~~~~~
/Users/doudouhe/.node-gyp/6.9.5/include/node/node_buffer.h:46:40: note:
candidate function not viable: 2nd argument ('const char ') would lose
const qualifier
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/node_buffer.h:34:40: note:
candidate function not viable: no known conversion from 'const char ' to
'v8::Localv8::String' for 2nd argument
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/node_buffer.h:31:40: note:
candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate, size_t length);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/node_buffer.h:39:40: note:
candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:793:12: error: no viable conversion from returned value of type
'v8::MaybeLocalv8::Object' to function return type
'v8::Localv8::Object'
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:218:7: note: candidate
constructor (the implicit copy constructor) not viable: no known
conversion from 'v8::MaybeLocalv8::Object' to 'const
v8::Localv8::Object &' for 1st argument
class Local {
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:218:7: note: candidate
constructor (the implicit move constructor) not viable: no known
conversion from 'v8::MaybeLocalv8::Object' to 'v8::Localv8::Object &&'
for 1st argument
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:222:13: note: candidate
template ignored: could not match 'Local' against 'MaybeLocal'
V8_INLINE Local(Local that)
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:800:26: error: no member named 'Use' in namespace 'node::Buffer'
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
~~~~~~~~~~~~~~^
../../nan/nan.h:827:32: warning: 'Compile' is deprecated
[-Wdeprecated-declarations]
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:1354:21: note: 'Compile' has
been explicitly marked deprecated here
Local<Script> Compile(Isolate* isolate, Source* source,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:834:32: warning: 'Compile' is deprecated
[-Wdeprecated-declarations]
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source);
^
/Users/doudouhe/.node-gyp/6.9.5/include/node/v8.h:1354:21: note: 'Compile' has
been explicitly marked deprecated here
Local<Script> Compile(Isolate* isolate, Source* source,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:1897:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Function]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../../nan/nan.h:1912:12: error: no matching function for call to
'_NanEnsureLocal'
return NanEscapeScope(node::MakeCallback(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../../nan/nan.h:120:25: note: candidate template ignored: substitution failure
[with T = v8::Value]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
14 warnings and 20 errors generated.
make: *** [Release/obj.target/lwip_decoder/src/decoder/init.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/doudouhe/WebstormProjects/svn/aladdin_proj/trunk/cpc/node_modules/blueimp-file-upload-expressjs/node_modules/lwip
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
[email protected] /Users/doudouhe/WebstormProjects/svn/aladdin_proj/trunk/cpc
└── (empty)

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "blueimp-file-upload-expressjs" "--save"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the lwip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs lwip
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls lwip
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/doudouhe/WebstormProjects/svn/aladdin_proj/trunk/cpc/npm-debug.log
npm ERR! code 1

save image in mongodb

I am trying to save edited file name in mongodb but doen't success.
someone can help me. to save edited file name in mongodb.
I use only express.js .

Updating the npm version to 0.4.5

The npm version (0.4.4) causes some problems under OS X because it uses lwip 0.0.6, the version on github works fine though (it uses lwip 0.0.8). I would very much appreciate updating the npm version to 0.4.5.

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the lwip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls lwip
npm ERR! There is likely additional logging output above.

I'm not sure what is the problem with the older version of lwip (maybe it's node 5.0 or OS X), but using the latest one does seem to solve the problem.

Generated url XML permanent redirect

The automatically generated urls cause a permanent redirect error when trying to access them (in an tag, etc.).

"The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint."

Added bucketUrl to the objects with the proper endpoint, which seems to work.

Edited source code of the node module on my local as follows:

sss = {url : (options.useSSL ? 'https:' : 'http:')+'//s3.amazonaws.com/'+options.storage.aws.bucketName+'/'+o.Key,
bucketUrl: (options.useSSL ? 'https:' : 'http:') +'//'+options.storage.aws.bucketName + '.s3.amazonaws.com/' + o.Key }

This produced an accessible url.

Update lwip dependency to 0.0.9

Version 0.0.8 doesn't install correctly on windows 10. It may be just my machine, but even installing 0.0.8 directly fails. That means to use this project I need to do a bunch of finagling with shrinkwrap to force it to use 0.0.9 as the required dependency.

Error as first parameter in callbacks

example from home page

    router.post('/upload', function(req, res) {
      uploader.post(req, res, function (obj) {
            res.send(JSON.stringify(obj)); 
      });

    });

uploader.post's callback only provides obj it should pass the error as first parameter if there is any error from aws s3 or null if there is not any error.

Use specific versions for package dependencies in package.json

It is very very dangerous to use * or latest version for package dependencies. Imagine Amazon releases an backwards-incompatible version of their aws-sdk under a new major version – this will break blueimp-file-upload-expressjs and thus breaking a ton of apps relying on this module.

FileInfo class lack file.path when used in local.js

when I use it for big files upload, I meet a issue about the request of "/update". Fallow the tutorial, there is my code on server.

# uploade.js
var options = {
    tmpDir:  __dirname + '/../public/points/tmp',
    uploadDir: __dirname + '/../public/points/files',
    uploadUrl:  '/pointsupload/uploaded/files/',
    storage : {
        type : 'local'
    }
};

var uploader = require('blueimp-file-upload-expressjs')(options);

router.get('/', function (req, res, next) {
    res.render('pointsupload');
});

router.get('/upload', function (req, res) {
    uploader.get(req, res, function (err, obj) {
        if(!err){
            res.send(JSON.stringify(obj));
        }
    });
});

router.post('/upload', function (req, res) {
    uploader.post(req, res, function (err, obj) {
        if(!err){
            res.send(JSON.stringify(obj));
        }
    });
});

router.delete('/uploaded/files/:name', function (req, res) {
    uploader.delete(req, res, function (err, obj) {
        if(!err){
            res.send(JSON.stringify(obj));
        }
    });
});

# app.js
var pointsupload = require('./routes/pointsupload');
app.use('/pointsupload', pointsupload);

When I enter "http: localhost:XX/pointsupload/upload" on the browser, I get some errors as follow.

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.basename (path.js:799:5)
    at getFileKey (D:\Tom\share\pointCloud\node_modules\blueimp-file-upload-expressjs\lib\fileinfo.js:12:17)
    at new FileInfo (D:\Tom\share\pointCloud\node_modules\blueimp-file-upload-expressjs\lib\fileinfo.js:24:16)
    at D:\Tom\share\pointCloud\node_modules\blueimp-file-upload-expressjs\lib\transport\local.js:24:40
    at Array.forEach (native)
    at D:\Tom\share\pointCloud\node_modules\blueimp-file-upload-expressjs\lib\transport\local.js:21:22
    at FSReqWrap.oncomplete (fs.js:123:15)

so I views the source of local.js and fileinfo.js. On 15:37 of local.js, It use FileInfo class which is defined on fileinfo.js, but it didn't define the "path" param.

get: function(callback) {
            var files = [],
                options = this.options;
            // fix #41
            options.saveFile = false;
            fs.readdir(options.uploadDir, function(err, list) {
                list.forEach(function(name) {
                    var stats = fs.statSync(options.uploadDir + '/' + name);
                    if (stats.isFile() && name[0] !== '.') {
                        var fileInfo = new FileInfo({
                            name: name,
                            size: stats.size,
                            lastMod: stats.mtime
                        }, options);
                        fileInfo.initUrls();
                        files.push(fileInfo);
                    }
                });
                callback(null, {
                    files: files
                });
            });
        },

but In the source of fileinfo.js, FileInfo class need file param has path property and getFileKey function use it.

function FileInfo(file, opts, fields) {
    this.name = file.name;
    this.size = file.size;
    this.type = file.type;
    this.modified = file.lastMod;
    this.deleteType = 'DELETE';
    this.options = opts;
    this.key = getFileKey(file.path);
    this.versions = {};
    this.proccessed = false;
    this.width = udf;
    this.height = udf;
    this.fields = fields;
    if (opts.saveFile) {
        this.safeName();
    }
}

Unconditionally making thumbnail directory.

On the line number 59, 'checkExists(options.uploadDir+'/thumbnail');', check directory and create it if not exist.

I think that when options.copyImgAsThumb is false, the new thumbnail directory should not be created.

Can't Read the image back

Images are uploaded well but cant read them back via url.
Any one got through the same problem or have any idea about the mis configuration.
(Using ExpressJs )

var options = {
tmpDir: __dirname + '/public/uploaded/tmp',
uploadDir: __dirname + '/public/uploaded/files',
uploadUrl: '/uploaded/files/',
maxPostSize: 11000000000, // 11 GB
minFileSize: 1,
maxFileSize: 10000000000, // 10 GB
acceptFileTypes: /.+/i,
// Files not matched by this regular expression force a download dialog,
// to prevent executing any scripts in the context of the service domain:
inlineFileTypes: /.(gif|jpe?g|png)/i,
imageTypes: /.(gif|jpe?g|png)/i,
copyImgAsThumb : true, // required
imageVersions :{
maxWidth : 200,
maxHeight : 200
},
accessControl: {
allowOrigin: '*',
allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',
allowHeaders: 'Content-Type, Content-Range, Content-Disposition'
},
storage : {
type : 'local',
aws : {
accessKeyId : 'xxxxxxxxxxxxxxxxx',
secretAccessKey : 'xxxxxxxxxxxxxxxxx',
region : 'us-east-1',//make sure you know the region, else leave this option out
bucketName : 'xxxxxxxxxxxxxxxxx'
}
}
};

app.get('/upload', function(req, res) {
  uploader.get(req, res, function (obj) {
        res.send(JSON.stringify(obj)); 
  });

});

app.post('/upload', function(req, res) {
  uploader.post(req, res, function (obj) {
        res.send(JSON.stringify(obj)); 
  });

});

// the path SHOULD match options.uploadUrl 
app.get('/uploaded/files/:name', function(req, res) {
  uploader.get(req, res, function (obj) {
        res.send(JSON.stringify(obj)); 
  });

});
app.delete('/uploaded/files/:name', function(req, res) {
  uploader.delete(req, res, function (obj) {
        res.send(JSON.stringify(obj)); 
  });

});

AWS transport doesn't mark files as processed when upload is done

When I upload a file using the AWS transport, the server hangs up. I read the code and it seems a line is missing:

this.upload(fileInfo.name, file.path, function(error,awsFile) {
  if(!error){
    fileInfo.awsFile = awsFile;
    fileInfo.proccessed = true; // <-- this line
    fileInfo.initUrls();
  }
  finish(error,fileInfo);
});

Am I right, or is there a reason this line isn't here? The local transport has it.

can`t install from npm

try the latest and some lower version but still telling:

"C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" install [email protected] --save

Exit code: 1

Standard error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)
gyp ERR! stack at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack at FSReqWrap.oncomplete (evalmachine.:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd E:\NodejsProjects\node-flasky\node_modules\blueimp-file-upload-expressjs\node_modules\lwip
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "[email protected]" "--save"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the lwip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls lwip
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! E:\NodejsProjects\node-flasky\npm-debug.log

Standard output:

[email protected] install E:\NodejsProjects\node-flasky\node_modules\blueimp-file-upload-expressjs\node_modules\lwip
node-gyp rebuild

E:\NodejsProjects\node-flasky\node_modules\blueimp-file-upload-expressjs\node_modules\lwip>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (rebuild)

image resize

When will this be ready? Can you implement it with node-canvas?

Thanks

I missing a "storage: 'buffer' " option

Hi, your module is cool. But in my actual project (a project-manager ;) ) I want to save some small attachments as buffer in my project –document on a MongoDB. So I can easily erase all project-data at once if a project is finished.

In this case I don’t have use for the “dir” and “url” options and would prefer to get the buffer and filename from the callback.

uploader.post function really slow to proceed, fs warning also

Hi,

I am using :

  • nodejs 0.10.35
  • blueimp-file-upload-expressjs 0.3.2
  • blueimp-file-upload (jQuery File Upload) 9.9.1
  • express 4.9.5
  • a 243KB jpeg file

When I upload a file, the post duration takes at least a minutes for a small file.

2015-01-12T23:15:17+01:00 starting upload with fn uploader.post
2015-01-12T23:16:19+01:00 end upload with fn uploader.post
Total upload duration 62835 ms

It can goes up to 200842 ms
I also often have this errors :

fs: missing callback Error: ENOENT, unlink 'E:\tmp\upload_e39027d4f0f91dd03c4a58da3711e3bf'

My configuration file looks like this

imageVersions: {
    maxWidth: 1800,
    maxHeight: 'auto',
    xxxlarge: {
        width: 1300,
        height: 'auto'
    },
    xxlarge: {
        width: 9999,
        height: 'auto'
    },
    xlarge: {
        width : 700,
        height: 'auto'
    },
    large: {
        width : 300,
        height: 'auto'
    },
    medium: {
        width : 140,
        height: 'auto'
    },
    xsmall: {
        width: 100,
        height: 'auto'
    }
}

By the way, considering the fileInfo.initUrls function

// L170
Object.keys(options.imageVersions).forEach(function(version) {
      if (_existsSync(
          options.uploadDir + '/' + version + '/' + that.name
        )) {
        that[version + 'Url'] = baseUrl + version + '/' +
          encodeURIComponent(that.name);
      }
    });

My model returned in obj.files should have these URI set as attributes with proper keys, but instead I have largeUrl and mediumUrl

"_id" : ObjectId("54b442e2e94c0bc00b6ec4ce"),
"creationDate" : ISODate("2015-01-12T21:55:46.481Z"),
"name" : "charlie2.jpg",
"size" : 908057,
"type" : "image/jpeg",
"deleteType" : "DELETE",
"url" : "http://localhost:8000/upload/charlie2.jpg",
"deleteUrl" : "http://localhost:8000/upload/charlie2.jpg",
"largeUrl" : "http://localhost:8000/upload/large/charlie2.jpg",
"mediumUrl" : "http://localhost:8000/upload/medium/charlie2.jpg",

large and medium folder are automatically created and used, same for xxlarge,xlarge... but URI is not in the model.

I have tried on different computers, all have the lag problem, this must be a problem with the library, I have looked inside the code, can't figure out where it got stuck of so long.

Any ideas ?

some AWS S3 problem

Hi
i am using this for my uploader, all will go the AWS S3
when i try it i have some problem

  1. when read the file form AWS the URL is not work the error is
    The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

then i change the code in the index.js line 250 to
url: (options.useSSL ? 'https:' : 'http:') + '//' + options.storage.aws.bucketName + '.s3-' + options.storage.aws.region + '.amazonaws.com/' + o.Key

them is can display correct, is that ok ?

  1. when post to aws that is no any thumbnail.

3.for the tmpDir the file will upload to it, those file will delete ?

thx
Gino

NPM install causes multiple errors

When trying to install into my project I get huge amounts of errors: npm install blueimp-file-upload-expressjs.

> [email protected] install /Library/WebServer/Documents/promise-or-pay/node_modules/blueimp-file-upload-expressjs/node_modules/lwip
> node-gyp rebuild

  CXX(target) Release/obj.target/lwip_decoder/src/decoder/init.o
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../node_modules/nan/nan.h:120:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:115:25: note: previous definition is here
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) {
                        ^
../node_modules/nan/nan.h:207:68: error: too many arguments to function call, expected at most 2, have 4
    return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
           ~~~~~~~~~~~~~~~~~~                                      ^~~~~~~~~~
/Users/username/.node-gyp/4.4.1/include/node/v8.h:4675:3: note: 'New' declared here
  static Local<Signature> New(
  ^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../node_modules/nan/nan.h:289:3: error: redefinition of 'NanNew'
  NanNew<v8::StringObject, v8::Handle<v8::String> >(
  ^
../node_modules/nan/nan.h:282:3: note: previous definition is here
  NanNew<v8::StringObject, v8::Local<v8::String> >(
  ^
../node_modules/nan/nan.h:307:36: error: redefinition of 'NanNew'
  NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                   ^
../node_modules/nan/nan.h:301:36: note: previous definition is here
  NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                   ^
../node_modules/nan/nan.h:319:36: error: redefinition of 'NanNew'
  NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                   ^
../node_modules/nan/nan.h:313:36: note: previous definition is here
  NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                   ^
../node_modules/nan/nan.h:531:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:536:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:541:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:546:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:778:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../node_modules/nan/nan.h:789:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/username/.node-gyp/4.4.1/include/node/node_buffer.h:31:40: note: candidate function not viable: no known conversion from 'uint32_t'
      (aka 'unsigned int') to 'enum encoding' for 3rd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/username/.node-gyp/4.4.1/include/node/node_buffer.h:43:40: note: candidate function not viable: 2nd argument ('const char *') would lose const
      qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/username/.node-gyp/4.4.1/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/username/.node-gyp/4.4.1/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../node_modules/nan/nan.h:793:12: error: no viable conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/username/.node-gyp/4.4.1/include/node/v8.h:210:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from
      'v8::MaybeLocal<v8::Object>' to 'const v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/username/.node-gyp/4.4.1/include/node/v8.h:210:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from
      'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object> &&' for 1st argument
class Local {
      ^
/Users/username/.node-gyp/4.4.1/include/node/v8.h:214:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/username/.node-gyp/4.4.1/include/node/v8.h:326:13: note: candidate template ignored: could not match 'S *' against 'v8::MaybeLocal<v8::Object>'
  V8_INLINE Local(S* that)
            ^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../node_modules/nan/nan.h:800:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
../node_modules/nan/nan.h:1897:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Function]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:1912:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(node::MakeCallback(
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Value]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../node_modules/nan/nan.h:1985:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(handle->Get(NanNew(key)).As<v8::Object>());
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:517:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../node_modules/nan/nan.h:120:25: note: candidate template ignored: substitution failure [with T = v8::Object]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {

16 errors generated.
make: *** [Release/obj.target/lwip_decoder/src/decoder/init.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Library/WebServer/Documents/promise-or-pay/node_modules/blueimp-file-upload-expressjs/node_modules/lwip
gyp ERR! node -v v4.4.1
gyp ERR! node-gyp -v v3.3.0
gyp ERR! not ok
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "blueimp-file-upload-expressjs" "--save"
npm ERR! node v4.4.1
npm ERR! npm  v2.14.20
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the lwip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs lwip
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls lwip
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Library/WebServer/Documents/promise-or-pay/npm-debug.log

error while running app

previous version of blueimp is working, but when i install new updated version, it shows bellow error,
how to solve this, even i install lwip seperately

module.js:355
Module._extensions[extension](this, filename);
^
Error: /home/pitu/node_modules/blueimp-file-upload-expressjs/node_modules/lwip/build/Release/lwip_encoder.node: undefined symbol: _ZN2v816FunctionTemplate3NewEPFNS_6HandleINS_5ValueEEERKNS_9ArgumentsEES3_NS1_INS_9SignatureEEE
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /home/pitu/node_modules/blueimp-file-upload-expressjs/node_modules/lwip/lib/Image.js:8:19
at Object. (/home/pitu/node_modules/blueimp-file-upload-expressjs/node_modules/lwip/lib/Image.js:471:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)

file.path undefined in fileinfo.js

There is a problem with the latest versions of nodejs.

In particular in fileInfo.js (line 24) there is the need to know the file path.

function FileInfo(file, opts, fields) { ... this.key = getFileKey(file.path); ... }

but in local.js (line 24) the path is not passed in the object:

var fileInfo = new FileInfo({ name: name, size: stats.size, lastMod: stats.mtime }, options);

The method getFileKey() return path.basename(filePath); but being undefined path that causes an error.

SSL support

You need to uncomment lines 45-52 of the module to be able to use this module in https for your express app.
It's not ok for users to have to go inside /node_modules to do that since npm install or npm update will break things.

The original code you forked from used options.ssl value to create the server. Now that your code doesn't really use options.ssl value anymore but only the fact that it is undefined, you can just replace it by a boolean options.useSSL that users can pass by parameter.

It's is now responsiblity of your package user to create the server anyway. He will be able to chose HTTP or HTTPS if he wants.

I can do the pull request and quick tests this week end if you want.

Regards,
Michel.

There's no way to upload and remove files from AWS S3.

I've followed the instructions in order to make it work but I could not do it, in order to upload files into S3 I had to edit the index.js file as follows:

...
var allFilesProccessed = false;

files.forEach(function(file, idx) {
    allFilesProccessed = true;
    file.proccessed = true;
});
...

The processed option was not being updated, so the post method died as pending.

I could not get to remove any file, the request to delete the file or files is being doing to the local host instead of aws s3.

Did someone have the same problem?

The aspect ratio is broken when resizing

I'm using file-upload on my express.js application to upload user profile pictures. The profile picture is 144x144, so I put these dimensions on the options, but the picture I get is not cropped to preserve aspect radio, and it looks ugly. Is there a way to crop instead of resize?

It cannot change options after creating fileuploader instance

I'm making web app like web hard as private project.
Sometimes I need upload file to different directory in my server, but this blueimp-file-upload-expressjs module can not change options value(such as uploadDir) after creating instance.

Temporarily, I'm making instances at all such above occasions by different options.
I think that this task may have a CPU calculate unnecessary initializing works.
So I want you to add APIs that can change options after creating instance.

Rename uploaded file

Hi,

Urgent functionality for file upload - file rename. I think it would be great if after file upload you coud rename the file.

Thumbnail creation for AWS

Hi, I don't know if this is the right place to make a request.
I tried to get the thumbnail creation to work for AWS but I couldn't.
Do you have any plans to include this in the future?
I also created a setter for the filename instead of the b() because at times I wanted it to overwrite the current image stored in S3

Issue after uploading first image to the server - Path must be a string. Received undefined

Hi ,

I am seeing an weird issue after using arvindr21/blueimp-file-upload-expressjs
First time it worked after fighting with the lwip ..
Now , the upload works for the first time .. next time when I load the page , get method on /upload is having issue.
app crashes. Deleting the "uploaded" directory completely and running the app works. But only for the first time.
Following is the error that I am seeing when the app crashes .

path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined

This is what I see in the log ..
Upgraded node to 6.4.0
Anyone seen this / any idea whats wrong ?

Note - I am getting the same issue even after cloning your sample repository - https://github.com/arvindr21/expressjs-fileupload

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.