Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Down::ChunkedIO (https://github.com/janko/down) #501

Open
raivil opened this issue Nov 22, 2022 · 0 comments
Open

Comments

@raivil
Copy link

raivil commented Nov 22, 2022

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::ChunkedIOclass.

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.

def extract_io_from(input)

Is it possible to PDF::Reader to support Down::ChunkedIO?

Any thoughts?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant