cURL / Mailing Lists / curl-library / Single Mail

curl-library

File write and reading using curl api

From: Ajeet kumar.S <ajeetkumar.s_at_jasmin-infotech.com>
Date: Sat, 12 Jul 2008 17:16:09 +0530

Hi All,

Thank you Joe N. But if we use CURLOPT_WRITEDATA , data = file_name we will
mention. Then it will copy the data into file_name(i.e filelike abc.txt or
any) it is possible when the data is coming from outer source(ex. like
server etc.) But we have data in buffer like char Receive_Http[102400], we
want to write this data into

File_name(ex like abc.txt) what we can use any curl API.I think we will use
CURLOPT_WRITEFUNCTION

And write callback function size_t function( void *ptr, size_t size, size_t
nmemb, void *stream);

 

fp= fopen(file_name, 'mode');

stream =fp;

size_t function( void *ptr, size_t size, size_t nmemb, void *stream)

{

   fwrite or fread(ptr, size, nmemb, stream );

 

}

Is it right or directly using CURLOPT_WRITEDATA and CURLOPT_READDATA we can
write data into file and read data from file.

 

Actually I want to write the buffer data into file and similary I want to
read file data in to a buffer using curl api.

 

Thank you.

Regards,

Ajeet Kumar Singh

 

 

 

 

 
Received on 2008-07-12