Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Original multipart file names #6

Closed
chjj opened this Issue Dec 16, 2011 · 0 comments

Comments

Projects
None yet
1 participant
Owner

chjj commented Dec 16, 2011

I originally tried to keep parted as simple as possible by returning the temporary paths to files with the timestamp (included for uniqueness) still in the filename. Leaving files only in req.body eventually seemed problematic, I ended up adding req.files for the middleware. After writing a few things dependent on parted, it is kind of annoying to have to remove the timestamp in order to get the original filename. I want to maybe just add a file object to the req.files object, but I worry about backward compatibility.

With this change, grabbing the original filename would entail:

var file = req.files.my_file.filename;  // original filename
var path = req.files.my_file.path;       // temporary path

A very simple object literal I have setup now looks like:

{
  path: part,
  filename: file,
  toString: function() {
    return part;
  }
}

With the toString for a kind of backward compatibility.

I would maybe add another property for file size, etc.

I don't know how many people rely on req.files being strings right now, so it's a tough call.

@chjj chjj closed this in 98bbd47 Dec 17, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment