There is a web server (a) on a hosting with limited disk space. And there is a remote server (b) with video files and unlimited disk space. The client requests a php-cURL proxy from the web server, which in turn uses cURL to request a video file on the remote server (c) and using callback returns the pieces of the video file to the client (a). Everything works fine, except for one. There is no need to save the contents of the video file on the hosting (b), while the video file from the remote server (c) is accumulated in the buffer and overloads the hosting disk memory of the server (b). Where it accumulates and how to clean it is difficult for me to understand. Any tricks with CURLOPT_BUFFERSIZE do not bring results. How to prevent buffering of the entire video file on the hosting (server b). Thanks!
<?php
$filename = "http://some.remote.video.server/mp4/V36.mp4";
$ch = curl_init($filename);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header)
{
return strlen($header);
}
);
bcurl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $body)
{
echo $body;
$len = strlen($body);
return $len;
}
);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_exec($ch);
curl_close($ch);
?>