On Thu, 27 Aug 2015 16:20:44 GMT, Louie Bacani Foronda wrote:
Hello Sir, the download now is much faster... one more thing how do I change the file name of the downloaded file?
void downloadFile(HTTPServerRequest req, HTTPServerResponse res) { string title = db.select("title","books",req.params["book_id"]); string file = buildNormalizedPath("./data/inventory/"~req.params["book_id"]~".epub"); scope(failure) res.writeBody("File Not Found"); // check if there is a way to change the filename to title serveStaticFile(file)(req, res); }
I haven't tried this, but adding the following before the call to serveStaticFile
should work:
res.headers["Content-Disposition"] = "attachment; filename=\"custom-name.epub\"";