I uploaded pdf documents on s3 using carrierwave and fog. Is there a way for users to preview content without downloading it?
Asked
Active
Viewed 768 times
0
-
By preview do you mean read the entire document or to be able to see some cover page? – Antarr Byrd Oct 06 '15 at 13:51
-
It will be CV. 1-2 page max. Would be great to see the entire document. But i'm interested in both solutions because i'm new to rails and i want to absorb as much as i can – FVG Oct 06 '15 at 13:58
-
I want users to have access to it without storing it somewhere in the file system. Every user has one CV. CV is on amazon s3. And i want to make CV visible while looking on user's show page. And i can't seem to find any ruby gem for this. – FVG Oct 06 '15 at 14:04
-
The solution I've posted below should work. I've seen a few issues posted concerning s3 problem but they seem to have been user issues. – Antarr Byrd Oct 06 '15 at 14:11
2 Answers
1
By the end of the day i realised that i might have not only pdf but other types of files. So in fog.rb i set public to false so it generates uniqe url's
config.fog_public = false
And in my view.html.erb i do a simple link_to so it would open document in a new window without saving it like this:
<%= link_to "View CV", @applicant.cover.attachment.url, :target => "_blank" %>
Maybe there is way to preview links but for the moment that's fine.

FVG
- 11
- 2
0
You might consider using PDF-JS. There is a Rails gem but it hasn't been updated in 2 years. I would probably just download the latest version.

Antarr Byrd
- 24,863
- 33
- 100
- 188