On Jul 14, 7:43 pm, Boris Zbarsky <[email protected]> wrote:
> Neale wrote:
> > Is what I would like to do theoretically possible, (e.g. by using the
> > associated nsiChannel) ?
>
> Easily.  But you're not; you're using XHR.  So this isn't really
> on-topic for this newsgroup... that said,

Where would be on-topic for "XHR won't do it, so is it possible with
nsiChannel?"

> >    var xhr = ...
> >    // do request
> >    var result = xhr.responseText;
>
> There are tutorials out there on doing this in such a way that |result|
> ends up with "binary" data in it.  More precisely, such that each
> character of |result| is a zero-padded byte value from the response
> data.  You need to set the right charset, basically.  Then you can
> URI-encode the bytes and use a data: URI.
>
> >    window.open("data:text/plain;base64 ," + result);
>
> Oh, if the server returns a base64-encoded string, that's even easier.
> Just do that, but use the right MIME type instead of text/plain?

Sorry.  I probably should have said:
- I am working on a client.  Changing the server is not an option.
- I'd prefer to be able to hand off the stream to a file, rather than
put what could be, say a Gig of data, into a string.

The XHR -> nsiChannel relevance is that I can do most of what I need
with standard XHR (e.g. track progress etc), but it seems I need to go
under the hood and use nsiChannel.

I've seen tutorials on using a binary charset, as you mention, but
nothing that's scalable or just gives me the same behaviour as when I
download a link.



_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network

Reply via email to