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.
To construct a Blob from other non-blob objects and data, use the Blob() constructor. To create a blob that contains a subset of another blob's data, use the slice() method. To obtain a Blob object for a file on the user's file system, see the File documentation.
A File object is created by passing in a string that represents the name of a file, a String, or another File object. For example, File a = new File("/usr/local/bin/geeks"); This defines an abstract file name for the geeks file in the directory /usr/local/bin.
BLOB stands for a “Binary Large Object,” a data type that stores binary data. Binary Large Objects (BLOBs) can be complex files like images or videos, unlike other data strings that only store letters and numbers. A BLOB will hold multimedia objects to add to a database; however, not all databases support BLOB storage.
A binary large object (BLOB or blob) is a collection of binary data stored as a single entity. Blobs are typically images, audio or other multimedia objects, though sometimes binary executable code is stored as a blob.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With