0

I am having a hard time recreating this code in python:

dtoIn.inputFile = new Blob([JSON.stringify({ financialTransactionList })], { type: "application/json" });

API only takes files as blob files and I am not sure how to convert pdf files into binary streams. So I tried to convert it using the IO library but I am not having the same result as in JS

    with open(file_destination, "rb", buffering=0) as pdf_file:
        binary = BytesIO(pdf_file.read())

How to do it right?

  • 1
    Does this answer your question? [Reading a binary file with python](https://stackoverflow.com/questions/8710456/reading-a-binary-file-with-python). First part of the first answer should be what you are looking for. `BytesIO` is not necessary in this case, simply `pdf_file.read()` (`binary` will be of type `bytes`). – felipe Oct 04 '21 at 15:02
  • I am sorry mate, it didn't. Thanks for the help anyway. I ended up rewriting the whole project because of this. – wolfrevo kcata Jan 09 '22 at 00:23

0 Answers0