2

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!

6
  • Do you want to upload a file? Commented Oct 11, 2019 at 6:26
  • bro fs.readFileSync this will look for a file at that path Commented Oct 11, 2019 at 6:32
  • I want to get the uploaded file's extension & size from Angular. But when I receive the request object in my node app, it's of type [object File] Commented Oct 11, 2019 at 6:32
  • So you are trying to upload file from angular to node js ? Commented Oct 11, 2019 at 6:32
  • You can use Multer npmjs.com/package/multer for uploading the file to the nodejs app. Commented Oct 11, 2019 at 6:33

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.