【发布时间】:2023-03-17 03:47:01
【问题描述】:
我正在尝试将上传的图像保存到我的流星项目的 public/images 文件夹中,所以我编写了这段代码。
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "images"})]
});
但是当我上传图片时,文件被保存到
.meteor/local/build/programs/server/images/
文件夹而不是 public/images 文件夹。
那么如何设置路径或将图像保存到 public/images 文件夹而不是 .meteor 文件夹?
我会解释为什么我需要它。
我还有另一个收藏,建筑物,它具有这种格式。
Schemas.Buildings = new SimpleSchema({
'name': {
type: String,
label: 'What is the name of the building?',
max: 200,
unique: true
},
'picture': {
type: String,
max: 200,
optional: true,
label: " ",
autoform: {
afFieldInput: {
type: 'fileUpload',
collection: 'Images',
accept: 'image/*',
label: 'Choose Aerial Image'
}
}
}
因为我需要设置带有图片的样板建筑,所以我需要将样板图片放到 public/images/ 文件夹中,并在 Meteor.startup bootstrap 中使用它们来设置样板建筑的图片值。
如果我把这些图像放到 .meteor 文件夹中,它会被流星重置命令删除,所以我希望将图像持久化到公共文件夹。
请教我!
【问题讨论】:
-
是否必须将文件存储在服务器上,或者您只想存储图像(例如一些免费的云服务将是更好的选择)?它易于配置,您可以很好地控制上传的文件。
-
让我编辑我的问题以获取更多详细信息。
标签: image meteor collectionfs