i have meteor application generates images. after generated, want serve them. each time write public folder, meteor server restarts. searched solution , found several workarounds:
serve files outside of project folder - @ moment don't know how achieve this, have write kind of middleware integrates meteor?
add tilde ~ folder in
public/- seems make meteor ignore folder altogether, when trying access files in folder redirected root page.run meteor in production mode. seems dirty workaround me. right now,
meteor run --productionstill restarts server have bundle app, reinstall fibers every time, set environment variables , run app. every time change something.
are there other solutions out there?
the accepted answer did not work me, of version 0.6.6.3 can following:
var fs = npm.require('fs'); webapp.connecthandlers.use(function(req, res, next) { var re = /^\/url_path\/(.*)$/.exec(req.url); if (re !== null) { // handle urls start /url_path/* var filepath = process.env.pwd + '/.server_path/' + re[1]; var data = fs.readfilesync(filepath, data); res.writehead(200, { 'content-type': 'image' }); res.write(data); res.end(); } else { // other urls have default behaviors next(); } }); notes
process.env.pwdgive project rootif plan put files inside project
- don't use
publicorprivatemeteor folders - use dot folders (eg. hidden folders ex:
.uploads)
not respecting these 2 cause local meteor restart on every upload, unless run meteor app with:
meteor run --production- don't use
Comments
Post a Comment