Skip to content

Instantly share code, notes, and snippets.

@xantiagoma
Created October 20, 2016 20:34
Show Gist options
  • Save xantiagoma/3296ce347882a794cecb4454d289ac37 to your computer and use it in GitHub Desktop.
Save xantiagoma/3296ce347882a794cecb4454d289ac37 to your computer and use it in GitHub Desktop.
router.get("/", auth.authenticate(), middle.getroles, middle.roles(["user"]), function (req, res){
if(req.query.path){
res.sendFile("/mnt/vol0/storage"+req.query.path, {}, function (err) { //I know this is dangerous
if (err) {
console.log(err);
res.status(500).json(err);
}
else {
console.log('Sent:', req.query.path);
}
})
}else{
res.sendStatus(404);
}
});
download: function(file){
console.log("Downloading...", file.file);
this.$http.get("/api/ftp", {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${this.$router.app.token}`
},
params: {
path: file.full
}
})
.then((data) => {
console.log(data);
window.debug = data;
let bfile = new Blob([data.data], {type: data.headers["Content-Type"]});
window.saveAs(bfile, file.file);
})
.catch((err)=>{console.error(err);});
}
//Vue-resource https://github.com/vuejs/vue-resource/blob/master/docs/http.md
@xantiagoma
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment