Skip to content
This repository

Zend\Http\Client does not support input streams #2645

Open
adamlundrigan opened this Issue · 4 comments

5 participants

Adam Lundrigan gullij Ralph Schindler ClemensSahs Enrico Zimuel
Adam Lundrigan

In ZF1, Zend_Http_Client supported input streams for PUT

$fp = file_open("mybigfile.zip", 'r');
$client->setRawData($fp, 'application/zip')->request('PUT');

This functionality no longer exists in ZF2 Zend\Http\Client, as ::setRawBody just proxies to Zend\Stdlib\Message::setContent, which only supports string-able input (scalars or objects with a __toString)

gullij

Is this ever getting fixed? This also causes the same error when trying to use the ZendGData classes to upload movies to YouTube.

I have no idea how to link this properly so here's the URL:

zendframework/ZendGData#6

gullij gullij referenced this issue in zendframework/ZendGData
Open

zendgdata is not compatible with zend-http #6

Ralph Schindler
Collaborator

@ezimuel Thoughts?

ClemensSahs

i work with this methode

$fp = fopen("mybigfile.zip", 'r');
$request->setContent( $fp );

// php5.3
$fileStat = fstat($fp);
$request->getHeaders()->addHeaderLine('Content-Length',$fileStat['size']);

// php5.4
$request->getHeaders()->addHeaderLine('Content-Length',fstat($fp)['size']);

$response = $client->send($request);

//////////////////////////////////////////////////////
// alternativ

$fp = fopen("mybigfile.zip", 'r');
$client->setRawBody($fp);
$fileStat = fstat($fp);
$request->getHeaders()->addHeaderLine('Content-Length',$fileStat['size']);
ClemensSahs

@adamlundrigan

is this issue done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.