How can we create a file object or a blob object in Node js? The object required should be same as we get while uploading a file from a form in HTML.
1 Answer
You can't directly create objects from the File API, because that's an API designed for the client side and implemented by browsers.
If you wanted to, you could implement those same objects yourself (the API is fully documented, of course), but it would probably make more sense to use NodeJS's file system API instead.
1 Comment
Vipul
Is the node js file api lets us create a file object? i mean i can access files i can do modfication and other stuff. But i specifically need to have a file object or a blob object as i want to test a api using Node js which takes in a file object as input
Buffer, well then, you can also fill aBufferwith binary data viafs.reador `fs.readSync' and use that