In the root project folder, there’s a main.html file, which is where I put in all my <head> stuff. Typically, this is where I would place the following code:
However, this requires me to receive the /assets/ route from FlowRouter and to serve the image being requested.
I found this issue on Github, and maybe I’m just dumb, but I don’t understand how I can make this work for my case in particular. That issue seems to be talking more about links regarding static files rather than simply serving the file itself. Either that or I’m completely off the mark. Thanks in advance.
Ah thanks! I was over-complicating things. Thanks, that worked! All I did was create a /public folder in the root project directory. I don’t know why I didn’t think that would work.
But what if a user could have no access to a file? For example, he tries to open .pdf file and has access, so I need to show that in new tab, but if he does not, I need to show “You have no access” instead. That’s the problem with static routs: if u have an ID of a document, u can get access directly to a file, if server gives it from public folder… What would u suggest?
Not sure if this solution would fit your use case, but I’m currently using meteorhacks:picker and something like:
Picker.route('/view/pdf', function (params, request, response, next) {
let pdfId = params.query.pdfId;
// let buf = a generated pdf file, using webshot and buffer
response.setHeader('Content-Type', 'application/pdf');
response.statusCode = 200;
response.end(buf);
});
And the url looks like: http://www.yourdomain.com/view/pdf?pdfId=somerandomstring. You can put auth in the route, and do things like return a non-200 response, etc.
thank you very much, i’m trying right now, but i got the problem: i need to set “X-Accel-Redirect” header. It is kinda res.writeHead(302, {“Location”: “/path/to”});, but not rly, would be nice to get some advice