Download and save file inside my extension folder in Firefox?

不羁的心 提交于 2021-01-28 04:48:00

问题


I would like to do the following from my firefox addon:

a). Determine my addons folder location.

b). Prompt the user to initiate a download.

c). Download and save the download

All the code examples available are for older API's and I have no clue on how to get them working for recent E10 (multi-process) code changes.


回答1:


A - Get addons folder location

var OSPath_addons = Services.dirsvc.get('XREUSysExt', Ci.nsIFile).path

B - Trigger download with path with no user notification

How to download image to desktop with OS.File

With user notification:

https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm#createDownload%28%29



来源:https://stackoverflow.com/questions/31539216/download-and-save-file-inside-my-extension-folder-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!