/lib/collections/images.js
var imageStore = new FS.Store.FileSystem("images", {
// what should the path be if I want to save to /public/assets?
// this does 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
}
});
});
},
});
对于路径,如果我使用:
path: "/public/assets/images",
错误:EACCES,权限被拒绝'/public'
path: "/assets/images",
错误:EACCES,权限被拒绝'/assets'
path: "~/assets/images",
这可行,但它会将图像保存到/home/assets/images
我的 Linux 机器上。该路径根本与 Meteor 项目无关。