In our rails app we use paperclip to save files to rackspace cloudfiles. We want to allow users to VIEW the files without needing to download them and use a program on their computer. We have found https://docs.google.com/viewer which looks good for the job
We have the following method in the controller:
def view
att = Attachment.find(params[:id])
redirect_to "http://docs.google.com/viewer?url=#{CGI.escape(att.file.expiring_url((Time.now + 60.seconds)).gsub(/^http:/, "https:"))}"
end
This generates the following url:
https://drive.google.com/viewerng/viewer?url=https://snet-storage101.syd2.clouddrive.com/v1/MossoCloudFS_4a360775-1b68-41f9-884f-e62e7567af25/container//attachments/files/000/003/488/original/AK-_Time_Recording.pdf?temp_url_sig%3Dd36797290b85f2dcd752xxxxxxe6a08951ad%26temp_url_expires%3D14xxxxx7408&u=0
The google docs viewer then tells us:
- Apologies, there is no preview available.
I suspect it has to do with the "temp_url_sig" and "temp_url_expires" parameters that are appended to the pdf file url.
Any ideas how we can get this to work?