Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a file object or Blob

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.

like image 435
Vipul Avatar asked May 15 '15 06:05

Vipul


People also ask

How do you create a BLOB object?

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.

How do you create a new file object?

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.

What is a file BLOB?

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.

What is a BLOB image?

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.


1 Answers

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.

like image 176
T.J. Crowder Avatar answered Oct 16 '22 16:10

T.J. Crowder