This is silly, because Zinc also only works with or needs binary streams.
But I have to know what kind of stream comes in, so I think it would not hurt
to implement
isBinary
"I am always binary"
^ true
Sven
On 20 Feb 2012, at 16:53, Stéphane Ducasse wrote:
> camillo
>
> I'm trying your script with the latest image.
>
>
> | f files|
> f := FSFilesystem disk workingDirectory / 'www.squeaksource.com' / 'Kozen'.
> files := f glob: [ :each| each basename endsWith: '.mcz'].
>
> files do: [ :file ||entity stream|
> stream := file readStream.
> (entity := ZnStreamingEntity type: ZnMimeType applicationOctetStream)
> stream: stream;
> contentLength: stream size.
> Transcript show: file; cr.
> "upload the version to gemstone"
> ZnClient new
> systemPolicy;
> beOneShot;
> signalProgress: true;
> ifFail: [ :exception | Transcript show: file basename; show: '
> '; print: exception ];
> username: 'sd' password: 'sn00py_';
> entity: entity;
> url: ( 'http://ss3.gemstone.com/ss/Kozen/', file basename);
> put ]
> displayingProgress: 'Uploading mcz'
>
>
> apparently FSReadStream does not know isBinary
>
>
>
> streamFrom: inputStream to: outputStream size: totalSize
> | bufferSize buffer leftToRead |
> bufferSize := 4096 min: totalSize.
> buffer := (inputStream isBinary ifTrue: [ ByteArray ] ifFalse: [ String
> ]) new: bufferSize.
> ^^^^^^^^^^
> leftToRead := totalSize.
> [ leftToRead > 0 ]
> whileTrue: [ | readCount |
> readCount := bufferSize min: leftToRead.
> inputStream next: readCount into: buffer.
> leftToRead := leftToRead - readCount.
> outputStream next: readCount putAll: buffer startingAt:
> 1 ]