[squeak-dev] Modern way to load a picture from the web?

H. Hirzel hannes.hirzel at gmail.com
Thu Mar 21 19:37:30 UTC 2019


It works if I replace

    #contentStream

with

   content asByteArray readStream

Form fromBinaryStream: (WebClient httpGet:
'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png')
content asByteArray readStream.

On 3/21/19, H. Hirzel <hannes.hirzel at gmail.com> wrote:
> Thanks for answering, Marcel
>
> On 3/21/19, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
>> What about ...
>>
>> Form fromBinaryStream: (WebClient httpGet:
>> 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png')
>> contentStream.
>
> Unfortunately a debugger window comes up [1]
>
>
>> ... I think we should add a #fromUrl: besides Form class >>
>> #fromFileNamed:
>> and there distinguish between file paths and HTTP urls etc:
>>
>> Form fromUrl:
>> 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png'.
>
> Yes, that would be fine to create a new convenience method
>
>      Form fromUrl:
>
> after we have figured out the solution.
>
> -- Hannes
>
> [1]
> SecureSocketStream(Object)>>doesNotUnderstand: #reset
> 	Receiver: SecureSocketStream[inbuf:4kb/outbuf:4kb]
> 	Arguments and temporary variables:
> 		aMessage: 	reset
> 		exception: 	MessageNotUnderstood: SecureSocketStream>>reset
> 		resumeValue: 	nil
> 	Receiver's instance variables:
> 		recentlyRead: 	0
> 		socket: 	a Socket[destroyed]
> 		inBuffer: 	#[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0...etc...
> 		outBuffer: 	#[71 69 84 32 47 119 105 107 105 112 101 100 105 97 47
> 99 111 109 10...etc...
> 		inNextToWrite: 	1
> 		outNextToWrite: 	1
> 		lastRead: 	0
> 		timeout: 	45
> 		autoFlush: 	true
> 		bufferSize: 	4096
> 		binary: 	true
> 		shouldSignal: 	true
> 		ssl: 	nil
> 		sendBuf: 	#[23 3 3 0 232 61 247 6 24 144 238 146 249 51 100 82 127
> 29 104 195 17...etc...
> 		readBuf: 	#[203 4 102 97 151 46 237 173 196 165 168 136 21 56 21 225
> 6 113 183 1...etc...
> 		decoded: 	a ReadStream
> 		certIssues: 	0
>
> [] in ImageReadWriter class>>formFromStream:
> 	Receiver: ImageReadWriter
> 	Arguments and temporary variables:
> <<error during printing>
> 	Receiver's instance variables:
> 		superclass: 	Object
> 		methodDict: 	a MethodDictionary(#atEnd->(ImageReadWriter>>#atEnd "a
> CompiledMethod...etc...
> 		format: 	65537
> 		instanceVariables: 	#('stream')
> 		organization: 	('accessing' nextImage nextPutImage:)
> ('stream access' atEnd close...etc...
> 		subclasses: 	{PCXReadWriter . XBMReadWriter . JPEGReadWriter .
> JPEGReadWriter2 ....etc...
> 		name: 	#ImageReadWriter
> 		classPool: 	a Dictionary(#ImageNotStoredSignal->nil
> #MagicNumberErrorSignal->nil...etc...
> 		sharedPools: 	nil
> 		environment: 	nil
> 		category: 	#'Graphics-Files'
>


More information about the Squeak-dev mailing list