Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

geting xpconnect wrapped nsIFile when passing file in formdata

58 views
Skip to first unread message

Ashwin Devarajan

unread,
Sep 8, 2016, 4:45:07 PM9/8/16
to dev-ext...@lists.mozilla.org
Hi,

I am trying to pass file [FileUtils.getFile()] in a formdata object to be
send to server in XMLHttpRequest. But all I get at server side is in
xpconnect wrapped nsIFile.

what I think is I am sending a xpcom wrapped file object to the formdata.
If in this case how can I send an actual file in formdata to be sent to
server?

Thanks in advance,
Aswin Devarajan
- Programmer Analyst, Firefox Student Ambassador
aswin5.github.io

David Rajchenbach-Teller

unread,
Sep 9, 2016, 2:23:33 AM9/9/16
to dev-ext...@lists.mozilla.org
Hi Ashwin,

If you use a XHR, you need to send the contents of the file, rather
than the file itself. If you are using XPCOM, as seems to be the case, I
suggest using `OS.File.read` to read the contents of the file, it's
simpler and faster than going through `FileUtils`.

However, I don't suggest using XPCOM for your add-on – it's on the way
out. There may be a way to read local files using the WebExtensions API,
which is way more robust and future-proof. Perhaps using the `downloads`
API [1]?

Cheers,
David

[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads
> _______________________________________________
> dev-extensions mailing list
> dev-ext...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-extensions
>

Ashwin Devarajan

unread,
Sep 9, 2016, 10:10:09 AM9/9/16
to David Rajchenbach-Teller, dev-ext...@lists.mozilla.org
Hi David,

Thank you.

I am getting my file.

I am developing an extension for thunderbird and I didn't find much
material on
internet to develop an thunderbird extension with web APIs. Most of them
are build using
XPCOM and XUL. That's why I choose to go with old ways.

Cheers,
Ashwin

- Programmer Analyst
aswin5.github.io
0 new messages