How to save to /public in Meteor with cfs:filesystem and collectionfs? -


/lib/collections/images.js

var imagestore = new fs.store.filesystem("images", {   // should path if want save /public/assets?   // not work   path: "/assets/images/",    maxtries: 1 });  images = new fs.collection("images", {   stores: [imagestore] });  images.deny({   insert: function() {     return false;   },   update: function() {     return false;   },   remove: function() {     return false;   },   download: function() {     return false;   } });  images.allow({   insert: function() {     return true;   },   update: function() {     return true;   },   remove: function() {     return true;   },   download: function() {     return true;   } }); 

/client/test.html

<template name="test">      <input type="file" name="myfileinput" class="myfileinput">  </template> 

/client/test.js

template.test.events({    'change .myfileinput': function(event, template) {     fs.utility.eachfile(event, function(file) {       images.insert(file, function (err, fileobj) {         if (err){            // handle error         } else {            // handle success         }       });     });   },  }); 

for path, if use:

path: "/public/assets/images", 

error: eacces, permission denied '/public'

path: "/assets/images", 

error: eacces, permission denied '/assets'

path: "~/assets/images", 

this works, saves image /home/assets/images on linux machine. path isn't relative meteor project @ all.

/ doesn't stand root of site. / stands root of system. meteor app runs user.

what you'll want do, use relative path. it's possible collectionfs fs.write operation isn't done apps root. alternatively use path: process.env.pwd + '/public/assets/images'


Comments