Is it possible to convert FileEntry
to standard JavaScript object File
?
I can't find anything meaningful in documentation https://developer.chrome.com/apps/fileSystem
The FileEntry
documentation does provide guidance here:
The
FileSystemFileEntry
interface of the File System API represents a file in a file system. It offers properties describing the file's attributes, as well as thefile()
method, which creates a File object that can be used to read the file.
Unfortunately file()
method relies on callbacks rather Promises, but we can wrap that and make using the API (and reading the code) easier:
async function getFile(fileEntry) {
try {
return await new Promise((resolve, reject) => fileEntry.file(resolve, reject));
} catch (err) {
console.log(err);
}
}
var file = await getFile(fileEntry);
Note that FileSystemFileEntry
is non-standard feature and is not a standards track, so the API and browser support may change!
I found how to do this in google examples https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/filesystem-access/js/app.js
var jsFileObject;
fileEntry.file(function (file){
jsFileObject = file
});
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