我已实现Meteor-CollectionFS用于在帖子中上传图片,并且一切正常,就像上传和显示图片一样。
现在,我正在进行版本控制,例如在上载图像时调整图像大小,并且给定名称为 @{
var result = "";
if (IsPost)
{
var firstName = Request["FirstName"];
var lastName = Request["LastName"];
var email = Request["Email"];
var userData = firstName + ", \n" + lastName +
", \n" + email + Environment.NewLine;
var dataFile = Server.MapPath("~/App_Data/data.txt");
File.WriteAllText(@dataFile, userData);
result = "Information saved.";
}
}
,请参见以下代码
thumb
我正在显示图像,就像
ProjectImages = new FS.Collection('ProjectImages', {
stores:[
new FS.Store.FileSystem("images", {
path: "~/files/images"
}),
new FS.Store.FileSystem("thumb", {
transformWrite: function(fileObj, readStream, writeStream){
gm(readStream, fileObj.name())
.resize('400', '350').stream()
.pipe(writeStream);
}
})
// new FS.Store.GridFS('ProjectImages')
],
filter: {
allow: {
contentTypes: ['image/*'],
extensions: ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG']
}
}
});
它显示的是未调整大小的原始图像,但是this.state.events.map((event, i) => (
....
<img src={ event.projectImage } />
....
显示的图像已调整大小,请参见下文
log
我的问题是如何显示FS.File._saveChanges: images
UPDATE: {"$set":{"copies.images":{"name":"dev.jpg","type":"image/jpeg","size":204521,"key":"ProjectImages-NSAxTejMyoQKZvQ6f-dev.jpg","updatedAt":"2018-11-29T08:08:33.230Z","createdAt":"2018-11-29T08:08:33.230Z"}}}
FS.File._saveChanges: thumb
UPDATE: {"$set":{"copies.thumb":{"name":"dev.jpg","type":"image/jpeg","size":24104,"key":"ProjectImages-NSAxTejMyoQKZvQ6f-dev.jpg","updatedAt":"2018-11-29T08:08:33.471Z","createdAt":"2018-11-29T08:08:33.471Z"}}}
......
图像而不是thumb
谢谢