arvindr21 / blueimp-file-upload-expressjs

A simple express module for integrating jQuery File Upload.
http://expressjs-fileupload.cloudno.de/
104 stars 69 forks source link

It cannot change options after creating fileuploader instance #2

Closed ssohjiro closed 10 years ago

ssohjiro commented 10 years ago

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.

arvindr21 commented 10 years ago

@ssohjiro I understand, but as of now the options are global to the module and is not passed by reference across functions. If I need to change that to a method level (get, post, delete), I need to run a check if the prerequisites (like folders & aws config etc..) are proper, for every single request.

This seemed more costly than having multiple single time instantiated uploaders. Let me know what you think.

arvindr21 commented 10 years ago

Closing as no response.

josh256 commented 9 years ago

AWS integration, how about:

var options = {
    //resume
    storage : {
        type : 'aws',
         aws : {
            accessKeyId :  'XXXXXXXXXXXXXXXXXXXXXXXX',
            secretAccessKey : 'XXXXXXXXXXXXXXXXXXXXXXXX',
            region : 'us-west-2',
            bucketName : 'mybucket'
        }
    }
};

exports.create = function(req, res) {

var id = req.params.id;  // if id = '645645646';

 options.storage.aws.bucketDir = id;  // will save on /mybucket/645645646/

  uploader.post(req, res, function (obj, redirect, error) {
    if(!error)
    {
      res.send(JSON.stringify(obj));
    }
  });

};

};

dinamic saving path on bucket

It´s posible? without creating new instances of the uploader?

arvindr21 commented 9 years ago

Thanks for proposing a solution @josh256 but if you can see the source code : https://github.com/arvindr21/blueimp-file-upload-expressjs/blob/master/index.js#L43 we are mapping the object when we init. Once the variable is in memory, we are have to update it on every upload.

josh256 commented 9 years ago

Yes I understand @arvindr21, I'm proposing a new option for future releases ;)

arvindr21 commented 9 years ago

Makes sense. Will keep this in mind next time I push something! Thanks!

josh256 commented 9 years ago

Thank you @arvindr21 :)