Reputation: 1128
I'm new to the programming world and I'm working with Rails to create my first project. I have a library of .pdf files saved on a separate shared network server. I would like to make links to some of these files so that when I click the link, the pdf opens in the browser.
I understand that by using:
<a href="/filename.pdf">Click Me</a>
I can open a file in the /public folder in my rails project, but I'm looking to open a file on a completely different harddrive. I've tried
`href="//drivename/folder/nextfolder/filename.pdf" `
but the browser gives me a 404 error saying file not found.
Upvotes: 3
Views: 3791
Reputation: 6786
Better use a controller action to serve the file:
say you have pdfs controller,
<a href="pdfs/serve/filename">Click Me</a>
def serve
path = "/drivename/folder/nextfolder/#{params[:filename]}"
send_file( path,
:disposition => 'inline',
:type => 'application/pdf',
:x_sendfile => true )
end
Upvotes: 7