Reputation: 1213
I used the paperclip gem to add an upload function for a pdf file. The upload works, once uploaded, the file is saved to location
/system/uploaded_files/sources/000/000/006/original/file.pdf
now I am trying to access this using the pdf reader
require 'pdf-reader'
require 'open-uri'
reader = PDF::Reader.new(open('/system/uploaded_files/sources/000/000/006/original/file.pdf'))
I get the following error
Errno::ENOENT: No such file or directory - /system/uploaded_files/sources/000/000/006/original/file.pdf
How do I access this file using the pdf-reader gem?
Upvotes: 1
Views: 1818
Reputation: 7624
Let's say your model is called PDF
and the asset is saved as file
.
class Pdf < ActiveRecord::Base
has_attached_file :file
end
Now try this:
p = Pdf.find(params[:id]) # get the object
reader = PDF::Reader.new(open(p.file.url))
Upvotes: 1