James Rudolf
James Rudolf

Reputation: 99

Node.js '[object File]' BLOB

I'm trying to obtain a BLOB from a request. The request object is constructed using FormData in Angular.

const buffer = fs.readFileSync(fileFromRequest);

The code above returns an error:

Error: ENOENT: no such file or directory, open '[object File]'

I can't find any resource to read/parse [object File].

Hope you guys can help me on this. Many thanks!

Upvotes: 2

Views: 8569

Answers (1)

Tony
Tony

Reputation: 20132

When upload a file using angular to node.js you cant use this

const buffer = fs.readFileSync(fileFromRequest);

The fs module only use to read to local file from the server. To handle upload data you can use multer

Upvotes: 1

Related Questions