Reference: FileReader.readAsDataURL
Considering the following example:
function previewFile(file) {
var reader = new FileReader();
reader.onloadend = function () {
console.log(reader.result);
}
reader.readAsDataURL(file);
}
It states:
instanceOfFileReader.readAsDataURL(blob);
blob: The Blob or File from which to read.
How can a local file URL like:
'file:///C:/path-to/root.png'
be passed to thereadAsDataURL()
Is
FileReader()
available in a Firefox Addon?
This information is outdated as of now, but cannot be deleted.
You can create
File
instances just by specifying a path when your code is chrome-privileged:File
is a sub-class ofBlob
, so allFile
instances are also validBlob
s. Please note that this requires a platform path, and not a file URL.Yes,
FileReader
is available to addons.File
andFileReader
are available in allwindow
s. If you want to use them in a non-window scope (likebootstrap.js
or a code module), you may usensIDOMFile
/nsIDOMFileReader
.