X-Accel-Redirect - showing instead force-download
September 14, 2016 11:57AM
yo guys, I'm searching for solution of my problem, mby some one has any clues about it. I need to show files preview (.pdf) to a users, who have access to that.:

Picker.route('/preview/:_id', function(params, req, res, next) {
console.log(params._id);
// checking for access
//...
//...
// res.setHeader('Content-Type', 'application/pdf');
// res.setHeader('Content-Disposition', 'inline');
res.setHeader('Content-Disposition', 'attachment; filename=designGuide.pdf');
res.setHeader('X-Accel-Redirect', 'http://localhost:8080/internal/designGuide.pdf');
res.end('');
});

as u can see, i'm redirecting to nginx and it works, but the problem with that, that the browser starting download instead showing .pdf file. Any suggests? PS: content-disposition: inline - not helps...
why im using x-access-redirect? Cause just imaging, if i'll send a file to a user with acces, he cans just copy source link to a file and send it to another user, without access - unacceptable.
Re: X-Accel-Redirect - showing instead force-download
September 16, 2016 08:45AM
My problem was in the nxing settings: i was needed to proxy meteor with nginx, but i did not. So now it looks like:

server {
listen %IP%:8080;
server_name localhost;
charset utf-8;

client_max_body_size 75M;

location /internal {
internal;
alias /webapp/.internal;
break;
}

location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # websocket header
proxy_set_header Connection "upgrade"; # websocket header
}
}

if u need to download the file in the browser tab - add res.setHeader('Content-Disposition', 'attachment; filename=designGuide.pdf'); else(preview) - don't.
Re: X-Accel-Redirect - showing instead force-download
September 16, 2016 08:57AM
fix last row: if u need download - set Content-Disposition, if u need preview - set Content-Type: application/pdf
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 111
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready