Compatibility with Down::ChunkedIO (https://github.com/janko/down)
raivil opened this issue · 0 comments
raivil commented
Hi,
I'm working with the Shrine gem and uploading PDF files to S3 (direct upload).
During the upload, the code is adding some metadata such as the page count.
I noticed that PDF::Reader accepts IO objects as input, but it's not working with the Down::ChunkedIO
class.
This is the code from the shrine uploader:
add_metadata do |file, metadata:, record:, **|
case metadata["mime_type"]
when "application/pdf"
io = file.to_io if file.respond_to?(:to_io)
reader = PDF::Reader.new(io)
{ page_count: reader.page_count }
Exception:
ArgumentError: input must be an IO-like object or a filename (Down::ChunkedIO)
Code from PDF::Reader that will try to read the IO object.
pdf-reader/lib/pdf/reader/object_hash.rb
Line 601 in 625e8dc
Is it possible to PDF::Reader to support Down::ChunkedIO
?
Any thoughts?
Thank you.