Re: How do download a binary file as a stream with Zinc?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: How do download a binary file as a stream with Zinc?

Mariano Martinez Peck


On Wed, Jul 25, 2012 at 11:46 AM, Sven Van Caekenberghe <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: How do download a binary file as a stream with Zinc?

Mariano Martinez Peck


On Wed, Aug 1, 2012 at 4:51 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Wed, Jul 25, 2012 at 11:46 AM, Sven Van Caekenberghe <[hidden email]> wrote:
Hi Mariano,

(I can't access the file you gave as an example, probably an extra #username:password: is needed)

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.


Hi Sven. Indeed, this last piece of code was what I was searching for. 
However, my "experiment" was to be able to directly revive test failures form Jenkins. 
But it turns out that it is not possible to have each .fuel separated...instead we have one big zip for all of them.
So at the end what Sean did is to have a zip with all .fuel files and the image itself. And he even wrote a UI for that. So my experiment ended there regarding Zinc.
anyway, at least I learnt how to do it. 
thanks Sven!

 
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




--
Mariano
http://marianopeck.wordpress.com