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

[V6] [letters.create] Trouble uploading PDF #211

Open
kdonovan opened this issue Mar 2, 2023 · 2 comments
Open

[V6] [letters.create] Trouble uploading PDF #211

kdonovan opened this issue Mar 2, 2023 · 2 comments

Comments

@kdonovan
Copy link

kdonovan commented Mar 2, 2023

I'm migrating from V5 to V6, and I'm having trouble uploading a PDF for the letters.create endpoint.

Specifically, when I pass in File.open("path-to-file.pdf") to the file argument of Lob::LetterEditable.new, the generated thumbnails in the Lob dashboard do add a page for the PDF, but it only contains a # character (see screenshot below).

Alternatives I have tried:

  • Passing just the local filename (not opening the file) -- yields "file must be a valid PDF or HTML file" (Lob::ApiError)
  • Passing File.read rather than File.open -- yields "source sequence is illegal/malformed utf-8" (JSON::GeneratorError)
    • (I also unsuccessfully tried various squish-to-valid-encodings methods from Ruby, but that doesn't feel like the right path)
  • Passing a variety of different input PDFs

Here is a minimal reproduction (just need to set LOB_API_KEY and ADDRESS_ID env vars):

#!/usr/bin/env ruby
require "lob"

config = Lob::Configuration.default
config.username = ENV.fetch("LOB_API_KEY")

api_client = Lob::ApiClient.new(config)
lob_letters = Lob::LettersApi.new(api_client)

pdf = File.open("tmp/input.pdf")

begin
  letter = Lob::LetterEditable.new({
    file: pdf,
    from: ENV.fetch("ADDRESS_ID"),
    to: ENV.fetch("ADDRESS_ID"),
    color: false,
    address_placement: "insert_blank_page",
    description: "Manual test script - PDF attachment issues"
  })

  puts lob_letters.create(letter).inspect
ensure
  pdf.close
end

And regardless of what file I use as tmp/input.pdf, this is the output in the Lob dashboard:

Screenshot 2023-03-02 at 9 51 59 AM

@BennyKitchell
Copy link
Contributor

Hey @kdonovan,

This is definitely a bug in our V6 release, I will add a ticket for the team to address this. I don't have a specific window for when we will be able to address it. If possible stay with V5 and I will update this comment when this issue is resolved.

Thanks!

@nilesmc
Copy link

nilesmc commented Nov 1, 2024

@BennyKitchell - Any update on this one? This is 1 of the issues blocking Kali and I from upgrading to V6.

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

No branches or pull requests

3 participants