On Tue, Jul 21, 2009 at 4:58 PM, Brian Mason <bmason@itassociates.com> wrote:

Greetings,

 

I am trying to take an image off the new and save it to a file.  This is what I have so far:

 

(FileStream newFileNamed: 'test.jpg')

                nextPutAll: ('http://freetalklive.com/images/amondson.jpg'  asUrl retrieveContents) getContentFromStream;

                close

 

The image exists, is found, and the file is written.  There is something wrong with the format of the local jpg.


Your stream needs to be "binary". Don't ask me more than about this; I only discovered it through trial, error and reading the code for HTTPSocket>>httpJpeg:

image := 'http://freetalklive.com/images/amondson.jpg'  asUrl retrieveContents.
f := (FileStream newFileNamed: 'test.jpg').
f binary.
f nextPutAll: image content.
f close.

or for your style of coding:

(FileStream newFileNamed: 'test.jpg') binary;

                nextPutAll: ('http://freetalklive.com/images/amondson.jpg'  asUrl retrieveContents) content;

                close.



Gulik.

--
http://gulik.pbwiki.com/