[squeak-dev] Download PDF using WebClient

Levente Uzonyi leves at elte.hu
Mon Oct 25 21:38:20 UTC 2010


On Mon, 25 Oct 2010, Bernhard Pieber wrote:

> Dear Squeakers,
>
> I have a problem downloading a PDF file using WebClient. I use the following code:
>
> 	| client resp file |
> 	client := WebClient new.
> 	[resp := client httpGet: 'http://dl.dropbox.com/u/6204244/mcs-ftl.pdf'.
> 	resp isSuccess ifFalse:[^self error: resp status].
> 	"Stream the content from the response"

Add this line here: resp contentStream binary.


Levente

> 	file := FileStream newFileNamed: 'mcs-ftl.pdf'.
> 	resp streamTo: file size: resp contentLength progress: nil.
> 	file close] ensure: [client close]
>
> I took the code from the WebClient Responses help page and only slightly modified it.
>
> The problem is that I can open the file with Preview but all the pages are blank. The downloaded file has 9.9 MB while the original has 7.2 MB. So clearly something went wrong. Maybe some problem with the encoding?
>
> Any idea how to fix that? I'd be most thankful.
>
> Cheers,
> Bernhard
>



More information about the Squeak-dev mailing list