Using php-opencloud, I manage to connect to trigger the download of my images. Large files (20, 30, or 50 GB).
Following the doc , with
$image = $service->getImage($image_id);
$stream = $image->downloadData();
I can see that Psr7 is downloading request body in a temp file /tmp/php...
but I simply can't figure how to redirect the data to store them in a persistent local file.
Using fopen, fwrite I had problem of memory exhaustion and a
$fp = fopen( $local_file, 'w' );
stream_copy_to_stream( $image->downloadData(), $fp );
triggers no error but $local_file is still at 0 bytes at the end.
How can I achieve this?
I tried during hours and I knew it was dumb as hell:
while( !$stream->eof() ) {
$buffer = $stream->read( 4096 );
fwrite( $fp, $buffer );
}
fclose( $fp );
is working nicely
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.