I want to use Zend_Rest_client to post a file to a certain url as follows:
$client = new Zend_Rest_Client('http://example.org/');
$client->arg('value1');
$client->arg2('value2');
$client->restPost();
I want to post a file in the body of the request. How could this be done ?
At this time it is not possible. While you do have access to the underlying Zend_Http_Client object used by the rest client, any options passed to it are reset prior to performing the rest request.
Because of this reset, you will not be able to upload a file as Zend_Rest_Client does not support it.
The function body for restPost is as follows:
Unfortunately,
_prepareRest()callsself::getHttpClient()->resetParameters()->setUri($this->_uri);which wipes out any file uploads or additional post parameters you have set and there is no way to prevent it at this time.See this issue Cannot send file using Zend_Rest_Client on the Zend Framework Issue Tracker. It looks like there has been some talk of a patch, but it doesn’t appear this functionality is going to be integrated any time soon.