Custom upload and download managers

I have been assigned the task of having our website launch a custom file chooser when the user is uploading and downloading files from our internal website. I have these programs already, but what I need to do is create an extension that will mediate between links on my website and the file chooser program.

So when the user clicks on a button to upload, my extension will intercept this request and call the file chooser. Then pass back the file and some extra information to my webpage for the actual upload.

And when the user clicks on a link(file) to download from my webpage, the extension will intercept this request and pass the file with some extra information to my file chooser so the file chooser can handle the saving to the hard drive.

I really have no idea how to write this extension and am hoping that I can get some help on this forum. If you know of any example extensions for me to look at or any other help you can give me, that would be awesome. Thanks.

While you can do the custom file chooser thing, saving files to the hard drive in arbitrary locations requires a companion application. Generally, you’ll want to look into content scripts, webRequest, the DOM file API, possibly downloads, indexedDB and connectNative/native messaging. You’ll find documentation for those on https://developer.mozilla.org/en-US/Add-ons/WebExtensions

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Working_with_files would probably be of special interest to you, depending on the high level goal of your extension.

Thanks, but I am on Firefox 45 and the new connect native will only work on 50.

Well, UPDATE!

(I rarely use cpas, but this deserves it)

1 Like

Have you ever worked for a company?
I do, and I’m not the president of the company either.
My customer is on Firefox 45 and I cannot make them update.

You can have an HTTP-server running on the system and contact that via localhost (or any public DNS name that resolves to 127.0.0.1, possibly a subdomain of your page, so that your main page and one served by the local server can booth set document.domain to effectovely become same-orogin pages).


Running a internet-connected software that is no longer being supplied with security updates is as inacceptable in a cooperative setting as it is for private users, if not more so.

Have you ever worked for a company?

I have worked in large, somewhat slow moving companies. Updating Firefox to a still-supported ESR shouldn’t be seen as “progress” but as standard maintenance.