Downloading sources file to image directory

120 Views Asked by At

I am using PharoCloud to host a Pharo image for me. By default it downloads a ZIP of the image only to my appliance; this ZIP doesn't include the .sources file.

I am trying to manually download the sources file with ZnClient. The directory my image is located in is /mnt/upload/upload.140605183221.

This is the code I have

| aFileStream |
    aFileStream := '/mnt/universe/upload/upload.140605183221/PharoV30.sources' asFileName writeStream.
    aFileStream write: (ZnClient new get: 'http://files.pharo.org/sources/PharoV30.sources.zip').
    aFileStream close.

I'm brand new to ZnClient; I don't know how to use it. What's wrong with my code?

2

There are 2 best solutions below

2
On BEST ANSWER

You can do this:

'./PharoV30.sources' asFileReference 
    writeStreamDo: [ :stream | 
        stream write: (ZnClient new get: 'http://files.pharo.org/sources/PharoV30.sources') contents ].
1
On

Nearly right. You need to replace the message #asFileName with #asFileReference, since #asFileName will answer a string object (so you actually get a WriteStream on the string).

fileReference := '/mnt/universe/upload/upload.140605183221/PharoV30.sources' asFileReference
fileReference writeStreamDo: [ :stream |
    | url|
    url := 'http://files.pharo.org/sources/PharoV30.sources.zip'.
    stream write: (ZnClient new get: url) ]