I'm working on a Chrome extension and I'd like to have the extension:
I see that the chrome.downloads API allows me to initiate the download and open the file, but is it possible for me to read the contents of the file (without writing native code)?
For security reasons, by default the Chrome browser does not allow extensions to access local files. If you want the accelerator to access local files (locations of "file:///...", instead of "http://" or "https://"), you must configure Chrome to allow the access.
Clicking the dropdown menu only gives you additional options. Always open files of this type. This changes the default setting so instead of saving the file, it will open it in the default program, then let you choose whether or not to save the file.
I'm copying the answer I gave here.
You just need to add a permission to file://*
in your manifest file and once you have your file's path in the system (with chrome.downloads.search
in the filename
property), make a GET XMLHttpRequest to the url file://{filepath}
.
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