How to upload binary content with Firefox extension?

前端 未结 1 1580
梦如初夏
梦如初夏 2021-01-24 04:26

In my Firefox extension I download the file, then the extension should upload it. I do the following -

// downloading fil         


        
相关标签:
1条回答
  • 2021-01-24 04:32

    Don't create the POST body yourself, instead use the FormData object.

    var formData = Components.classes["@mozilla.org/files/formdata;1"].createInstance(Components.interfaces.nsIDOMFormData);
    formData.append(key, value);
    
    formData.append("file", File(file));
    
    0 讨论(0)
提交回复
热议问题