Hmm, the following all work for me (in Pharo 7.0.1 on macOS): ZnClient new url: 'https://github.com/biosmalltalk/biopharo/raw/develop/test_files/BioSmalltalk...'; get; yourself. ZnClient new url: 'https://github.com/biosmalltalk/biopharo/raw/develop/test_files/BioSmalltalk...'; get; contents. ZnClient new get: 'https://github.com/biosmalltalk/biopharo/raw/develop/test_files/BioSmalltalk...'. ZnClient new url: 'https://github.com/biosmalltalk/biopharo/raw/develop/test_files/BioSmalltalk...'; downloadTo: '/tmp'. $ ls -lah /tmp/BioSmalltalkTestFiles.zip -rw-r--r--@ 1 sven wheel 5.3M Jan 26 22:57 /tmp/BioSmalltalkTestFiles.zip $ file /tmp/BioSmalltalkTestFiles.zip /tmp/BioSmalltalkTestFiles.zip: Zip archive data, at least v2.0 to extract
On 26 Jan 2019, at 20:36, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
Hi there,
In Pharo 7.0 I've encountered an error related with the new streams changes (https://github.com/pharo-open-documentation/pharo-wiki/blob/master/Migration...) while downloading a zip file. Problem is ZnUTF8Encoder expects a String, but my code which worked in Pharo 6 provides a ByteArray. I've isolated it in a reproducible way:
| webClient resp | webClient := ZnClient new. UIManager default informUserDuring: [ :bar | bar label: 'Downloading resources for ' , self class printString. [ webClient signalProgress: true; get: 'https://github.com/biosmalltalk/biopharo/raw/develop/test_files/BioSmalltalk...' ] on: HTTPProgress , ZnEntityTooLarge do: [ : ex | (ex isKindOf: ZnEntityTooLarge) ifTrue: [ ex resume ] ifFalse: [ | progress | progress := ex. progress isEmpty ifFalse: [ bar current: progress percentage. progress total ifNotNil: [ :aTotalNumber | bar label: 'Downloading ' ] ]. progress resume ] ] ]. (resp := webClient response) isSuccess ifTrue: [ 'output2.zip' asFileReference writeStreamDo: [ : stream | stream nextPutAll: resp contents ] ] ifFalse: [ self error: 'Cannot download resource files' ].
I also tried using #writeOn: on the response, but that also wrote the response header:
self response writeOn: 'test1.zip' asFileReference writeStream. self response writeOn: 'test2.zip' asFileReference binaryWriteStream.
HTTP/1.1 200 OK Via: 1.1 varnish Strict-Transport-Security: max-age=31536000 ...
PK ø à D BioSmalltalkTestFiles/PK ýU?+*8!" K / BioSmalltalkTestFiles/A4A7DS6V01S-Alignment.xmlÃÂÃÅksÃâºH Ãâ ÿà ïèà Ãâ¡Ã©à "Ãâù_ à æ: 0 R$`ðjSS.,aÃâº
Any suggestion?
Cheers,
Hernán