Encoding/Decoding PDF for react-pdf

I am trying to encode a PDF with BSON, pass the buffer into MongoDB via Mongoose, and then fetch the data from the database, deserialize it, and render the PDF using react-pdf. However, I am currently getting the following error:

Error: Invalid parameter object: need either .data, .range or .url

Based on my troubleshooting, it would seem that my problem is coming from the process of encoding/decoding. Before I encode, this is my PDF file:

  1. File {name: “9 Of The Most Popular Project Management Methodologies.pdf”, lastModified: 1599512408120, lastModifiedDate: Mon Sep 07 2020 17:00:08 GMT-0400 (Eastern Daylight Time), webkitRelativePath: “”, size: 494879, …}
  2. lastModified: 1599512408120
  3. lastModifiedDate: Mon Sep 07 2020 17:00:08 GMT-0400 (Eastern Daylight Time) {}
  4. name: “9 Of The Most Popular Project Management Methodologies.pdf”
  5. size: 494879
  6. type: “application/pdf”
  7. webkitRelativePath: “”
  8. proto: File

You’ll notice the File prototype and also that it is labelled “File” at the start (I’m not sure what that label is called).
Now, after I have decoded it, this is the file:

  1. {name: “9 Of The Most Popular Project Management Methodologies.pdf”, lastModified: 1599512408120, lastModifiedDate: Mon Sep 07 2020 17:00:08 GMT-0400 (Eastern Daylight Time), webkitRelativePath: “”, size: 494879, …}
  2. lastModified: 1599512408120
  3. lastModifiedDate: Mon Sep 07 2020 17:00:08 GMT-0400 (Eastern Daylight Time) {}
  4. name: “9 Of The Most Popular Project Management Methodologies.pdf”
  5. size: 494879
  6. type: “application/pdf”
  7. webkitRelativePath: “”
  8. proto: Object

As you can see, it is now just a generic object.

Is there a way to encode/decode a PDF file (or any file) while maintaining this prototype information? Am I perhaps doing something else wrong? React-PDF should be working regardless, as I’m pretty sure the object still has a .data parameter… Though I will double check that. I know the file must because it renders fine before I encode it.

Any and all help is very much appreciated!

Sorry I don’t really like to bump things but I could really use help with this.