可能重复:Meteor collectionfs insert server side
我有多个图像集合使用GridFS来存储文件。如果我使用“图像”作为集合的名称一切正常,但一旦我更改了名称,我就会GET http://localhost:3000/cfs/files/PlayerImages/zo4Z7rnYLb32MLYkM/taylor.jpg 403 (Forbidden)
(例如,这个确实有效:http://localhost:3000/cfs/files/Images/7j9XAEebGctuivGhz/see-more.png)
这就是我定义集合的方式:
function createImageCollection(name,transform){
var collectionName = name + 's';
var storeName = name + 'Store';
var options = {
filter: {
allow: {
contentTypes: ['image/*'],
extensions: ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG']
}
}
};
if (Meteor.isServer) {
storeOptions = {
path: process.env.PWD + "/public"
};
// only add the transform when graphicsmagick is available
if(gm.isAvailable && typeof transform === 'function'){
storeOptions.transformWrite = transform;
}
options.stores = [new FS.Store.GridFS(storeName,storeOptions)];
} else {
options.stores = [new FS.Store.GridFS(storeName)];
}
return new FS.Collection(collectionName,options);
}
// and finally create them
// THIS FIRST ONE WORKS JUST FINE
Images = createImageCollection('Image',imageResizeTimeline); // default resize is timeline, nothing bigger then that?
BackgroundImages = createImageCollection('BackgroundImage',imageResizeBackground);
PlayerImages = createImageCollection('PlayerImage',imageResizePlayer);
LogoImages = createImageCollection('LogoImage',imageResizeLogo);
我还为每个集合添加了允许/拒绝规则:
var ImagePermissions = {
insert: function () {
return true;
},
update: function () {
return true;
},
download: function () {
return true;
},
remove: function () {
return false;
},
fetch: null
};
Images.allow(ImagePermissions);
PlayerImages.allow(ImagePermissions);
BackgroundImages.allow(ImagePermissions);
LogoImages.allow(ImagePermissions);
在旁注中,我使用autoform生成表单,但我不认为问题位于那里,因为“Images”有效。
我必须将此路径添加到某些“路由”或“配置”文件中吗?也许默认情况下会添加“图片”? (这个项目是由其他人设置的,但我不认为我错过了他所做的任何事情。)