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:
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 addingreq.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 thereq.files
object, but I worry about backward compatibility.With this change, grabbing the original filename would entail:
A very simple object literal I have setup now looks like:
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.