Search code examples
node.jsfilepdf7-bit

Read a File Object with nodejs


Is it possible to read a file object in nodejs?

This is an example of an object that I'm talking about

"attachment1" : {
    "data" : [ 37, 80, 68, 70, ... ],
    "encoding" : "7bit",
    "mimetype" : "application/pdf",
    "name" : "Dalliny_Coelho_A_Ferreira.pdf",
    "size" : 6427,
    "truncated" : false
  }

My dream would be able to read it's contents as if it was HTML, since it's a PDF


Solution

  • I figured out afterwards that the data attribute was a ArrayBuffer of the file content, and that is basically what needs to be read. It's also what is returned when you read a file with the HTML 5 native file input