cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Help with partial file upload - result 18 - (0 bytes)

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 31 Oct 2006 15:32:09 -0800

On Tue, Oct 31, 2006 at 03:50:54PM -0700, Leon Vanderploeg wrote:
> I am new to cURL, and am trying to make it work. I have been able to get to
> a successful connection, but the file is always 0 bytes (result 18).

[...]

> size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
> {
> size_t retcode;
>
> int fd = (int)stream;
>
> printf("fd is %d: \n",fd);
>
> retcode = read(fd, ptr, size * nmemb);

[...]

> hd_src = fopen(LOCAL_FILE, "rb");

You're opening the file with fopen() but using read() to read from it. That's
mixing metaphors. Either replace fopen() with open() or read() with fread().

> hd = open(LOCAL_FILE, O_RDONLY) ;
> fstat(hd, &file_info);
> close(hd) ;

While we're here, you can use lstat() here and avoid the superfluous
open/close.

> curl_easy_setopt(curl, CURLOPT_USERPWD, "simple_at_vaultnow.com:s1mpl3");

I hope this isn't your real password, or it is now very simple for
someone to break in to your account.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-11-01