curl / Mailing Lists / curl-library / Single Mail


Re: SFTP Write/Read Callback mechanism

From: Daniel Stenberg <>
Date: Sun, 13 Aug 2017 18:04:24 +0200 (CEST)

On Sun, 13 Aug 2017, Krishnaraj wrote:

> What will be memory requirements for upload/download. I am asking this
> because the size of the files is not known prior before calling curl API. In
> ftpget example, I could see that in write callback the buffer is written to
> the file directly. Does it mean that curl internally allocates memory for
> the complete file and the callback gets triggered after obtaining complete
> file from remote server ?

libcurl delivers the data to the callback or reads it with a callback in a
streaming fashion and will not keep the entire file in memory either on upload
nor download. The size of the internal buffers for download and uploads is
16KB by default but can in fact be somewhat controlled with CURLOPT_BUFFERSIZE
in modern libcurl versions.

Received on 2017-08-13