[Pharo-project] How do download a binary file as a stream with Zinc?

Mariano Martinez Peck marianopeck at gmail.com
Wed Jul 25 12:40:13 EDT 2012


On Wed, Jul 25, 2012 at 11:46 AM, Sven Van Caekenberghe <sven at beta9.be>wrote:

> Hi Mariano,
>
> (I can't access the file you gave as an example, probably an extra
> #username:password: is needed)
>
>
Yes, in fact, that was the problem ;)


> You are making it more difficult than it has to be: this gives you the
> bytes you want
>
> ZnClient new
>         get: 'http://zn.stfx.eu/zn/string.fuel'.
>
> With some better system parameters this becomes
>
> ZnClient new
>         systemPolicy;
>         beOneShot;
>         accept: ZnMimeType applicationOctetStream;
>         url: 'http://zn.stfx.eu/zn/string.fuel';
>         get.
>
> But what you really want is something like:
>
> ZnClient new
>         systemPolicy;
>         beOneShot;
>         accept: ZnMimeType applicationOctetStream;
>         url: 'http://zn.stfx.eu/zn/string.fuel';
>         contentReader: [ :entity | FLMaterializer
> materializeFromByteArray: entity contents ];
>         get.
>
> You can experiment with #streaming: true but that is only worth it for
> large (MB) files. IMHO.
>
>
Thanks Sven, very informative.



> HTH,
>
> Sven
>
> On 24 Jul 2012, at 23:06, Mariano Martinez Peck wrote:
>
> > Hi Sven. How can I download a binary file to a bytearray ?
> >
> > I tried to download it locally doing:
> >
> >       ZnClient new
> >         systemPolicy;
> >         accept: ZnMimeType applicationOctetStream;
> >         url: '
> https://ci.lille.inria.fr/pharo/view/Pharo%202.0/job/pharo-2.0-tests/Architecture=32,OS=mac/ws/Pharo-2.0-AfterRunningTests/ClassHierarchyTest-testMethodDuplication.fuel
> ';
> >         downloadTo: '/Users/mariano/Desktop'.
> >
> >
> > but I cannot even do that. Notice that my final go is not to download it
> to a file, but rather directly get the binary contents.
> >
> > How can I do that?
> >
> > Thanks,
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
>
>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20120725/83778b23/attachment-0001.html>


More information about the Pharo-dev mailing list