I want to upload a simple file using skipper. Earlier, files uploaded via forms could be accessed using req.files but got to know that in Sails 0.10.x, with skipper installed by default, req.files is undefined. Instead of that req.file('filename') is used to access the file.
I could do a simple file upload looking at the documentation. However, I want to be able to access the file name before uploading it and also need to
- Upload the file to a dynamically created directory based on the user who uploaded it
- The name of the newly created file should be oldFileName + _ + timestamp in integer
How can I do this using skipper module or rather what is the most efficient way of doing this ?
EDIT
So far I have been able to do this but I am hoping there must be a better way.
For accessing the filename, I used this expression
var inputFileName = req.file('inputFile')._files[0]["stream"]["filename"];
I could see that skipper automatically creates the directory if its not present based on the filepath and name given in the parameter to upload function