

This way the file can be downloaded or shown up as an image, as a part of canvas etc.Īnd if we’re going to send a File over a network, that’s also easy: network API like XMLHttpRequest or fetch natively accepts File objects. We could want to read and process data all at the same time, outputting the processed data or performing other actions based on what we read. Just as we did with blobs, we can create a short url with URL.createObjectURL(file) and assign it to or. In many cases though, we don’t have to read the file contents.

Data url, base-64 encoded ( readAsDataURL).We usually get File objects from user input, like or Drag’n’Drop events ( ondragend).įileReader objects can read from a file or a blob, in one of three formats:
#READING FILE TIME PLUS#
In addition to Blob methods and properties, File objects also have name and lastModified properties, plus the internal ability to read from filesystem. That’s only inside a Web Worker though, because delays in synchronous calls, that are possible while reading from files, in Web Workers are less important. Its reading methods read* do not generate events, but rather return a result, as regular functions do. The most widely used events are for sure load and error.įor Web Workers, there also exists a synchronous variant of FileReader, called FileReaderSync.
