cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Fwd: Downloaded File (.pdf) Corrupt

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 7 Jan 2012 13:39:13 -0800

On Sat, Jan 07, 2012 at 03:11:28PM -0500, Eric Belec wrote:
> libcurl (.net) with C# :
>
> I determined that 9 out of 10 times downloading my various pdf files will work.
> The problem is the 1 of 10 times where the pdf returned was 22kb (and corrupt)
> instead of a working pdf of size 40kb...
>
> Please let me know if there is an alternate way I can write my pdf out.. I've
> spent so much time and I'm at the end of the ropes.. Any help would be
> appreciated! Below is the key code areas..

> public Int32 OnWriteFile(Byte[] buf, Int32 size, Int32 nmemb, Object
> extraData)
> {
>
> binaryWriter.Write(buf, 0, nmemb);

This should be size * nmemb as well.

>
> return size * nmemb;
> }

Are you sure the source PDF file isn't actually corrupt? Are you sure the
server isn't actually corrupting it somehow? Can you download the file
another way and tell? If you download the file from the same URL using
another program, is it corrupt? In what way is it corrupt? Is it simply
truncated? Are the non-truncated bytes correct? What do you see in the
transfer with logging enabled? What is the value returned by
easy.Perform()?

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-01-07