Im a mobile app developer and new to web apps. Im trying to implement upload and download a file in the web app using MeanJS stack. I have used multer plugin to upload file to server. After a lot of googling I have successfully used Multer which uploads and saves the files to uploads directory. Now Im trying to implement download the same, and I don't have an idea to do this. I have followed two methods:
<a target="_self" href="/uploads/{{eachDocument.modifiedFileName}}" download="{{eachDocument.fileName}}">{{eachDocument.fileName}}</a>
- Have used a route in the express server controller, as given in http://expressjs.com/api.html#res.download
Using the method #1 application never downloads the file with an error "Not a file", because uploads is not the public directory.
Using method #2, I'm able to get the raw file content, but not sure how to save the file.
Can anyone please tell me how to implement the file download that are saved in uploads directory that were uploaded using multer.
Thanks