Javascript FS.Store.GridFS createdByTransform:false
我正在尝试保存正在使用的图像文件 但是失败了。 图像模型Javascript FS.Store.GridFS createdByTransform:false,javascript,angularjs,node.js,meteor,angular-meteor,Javascript,Angularjs,Node.js,Meteor,Angular Meteor,我正在尝试保存正在使用的图像文件 但是失败了。 图像模型 /** * Create collections Images * @type {FS.Collection} */ Images = new FS.Collection("images", { stores: [ /** * Use GridFS stores */ new FS.Store.GridFS("original"), new
/**
* Create collections Images
* @type {FS.Collection}
*/
Images = new FS.Collection("images", {
stores: [
/**
* Use GridFS stores
*/
new FS.Store.GridFS("original"),
new FS.Store.GridFS("thumbnail", {
transformWrite: function(fileObj, readStream, writeStream) {
gm(readStream, fileObj.name()).resize('32', '32', '!').stream().pipe(writeStream);
}
})
],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
下一步,在控制器中保存图像
this.saveCroppedImage = () => {
if (this.myCroppedImage !== '') {
Images.insert(this.myCroppedImage, (err, fileObj) => {
if (!this.newParty.images) {
this.newParty.images = [];
}
console.log(fileObj);
this.newParty.images.push(fileObj);
this.cropImgSrc = undefined;
this.myCroppedImage = '';
});
}
};
fileObj没有url()方法。若尝试获取图像链接,则捕获503错误。但是如果在浏览器中放置链接-图像存在如果使用angular meteor和图像。收藏中存在id-不订阅收藏图像-在客户端上使用此功能
var getImageLink = function (imageId, store = "thumbnail") {
var authToken = FS.Utility.btoa(JSON.stringify({
authToken: Accounts._storedLoginToken() || '',
}));
return "/cfs/files/images/"+imageId+"?token="+authToken+"&store="+store;
}
如果您使用angular meteor和image.\u id存在于集合中-不订阅集合图像-请在客户端上使用此功能
var getImageLink = function (imageId, store = "thumbnail") {
var authToken = FS.Utility.btoa(JSON.stringify({
authToken: Accounts._storedLoginToken() || '',
}));
return "/cfs/files/images/"+imageId+"?token="+authToken+"&store="+store;
}