在已部署的 Meteor 应用程序中动态添加图像
Dynamically add images in deployed Meteor app
我部署了一个 Meteor 应用程序,允许我的管理员用户上传图像、音频和视频。我使用 meteor-uploads 上传文件,优化媒体,并放入 public/images、public/video 等
然而,虽然媒体文件放置在正确的位置,但应用程序看不到它们——尽管它确实看到 public/images 中已部署的其他文件。
root@doc# pwd
/home/secrethistory/bundle/programs/web.browser/app
root@doc# ls images/menuburger.png images/add.png
images/add.png images/menuburger.png
显然,为了热部署这些图像,我需要用 Meteor 注册它们。我该怎么做?
这不是一个新挑战,我偶然发现了一些解决方法。
显然,Meteor 不允许您即时添加资产,因为它们必须在 meteor 的清单中才能为它们提供服务。
最直接的解决方案是单独提供 "public" 文件。例如,使用 nginx,在 /etc/nginx/sites-enabled/yourwebsite
中,我们将节点配置为在 meteor 之外提供媒体文件。
location /audio/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}
location /video/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}
location /images/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}
我部署了一个 Meteor 应用程序,允许我的管理员用户上传图像、音频和视频。我使用 meteor-uploads 上传文件,优化媒体,并放入 public/images、public/video 等
然而,虽然媒体文件放置在正确的位置,但应用程序看不到它们——尽管它确实看到 public/images 中已部署的其他文件。
root@doc# pwd
/home/secrethistory/bundle/programs/web.browser/app
root@doc# ls images/menuburger.png images/add.png
images/add.png images/menuburger.png
显然,为了热部署这些图像,我需要用 Meteor 注册它们。我该怎么做?
这不是一个新挑战,我偶然发现了一些解决方法。
显然,Meteor 不允许您即时添加资产,因为它们必须在 meteor 的清单中才能为它们提供服务。
最直接的解决方案是单独提供 "public" 文件。例如,使用 nginx,在 /etc/nginx/sites-enabled/yourwebsite
中,我们将节点配置为在 meteor 之外提供媒体文件。
location /audio/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}
location /video/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}
location /images/ {
root /home/secrethistory/bundle/programs/web.browser/app;
}