chjj/parted — Issue #6: Original multipart file names
Author: chjj
Created: 2011-12-16 11:33:31+00:00
State: open

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:

``` js
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:

``` js
{
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.