|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Question for Zend_Rest_Client/ServerIs there an easy way to send binary data over POST to a
Zend_Rest_Server? I didn't see that kind of example on the documentation but I need to send binary data(image) to a REST service? Thanks in advance, Georgi |
|
|
Re: Question for Zend_Rest_Client/ServerOn 3/12/08 10:55 AM, Georgi Sokolov wrote:
> Is there an easy way to send binary data over POST to a > Zend_Rest_Server? I didn't see that kind of example on the documentation > but I need to send binary data(image) to a REST service? In version 1.5 of the Zend Framework, you'll be able to easily access the raw POST data from a controller with $this->getRequest()->getRawBody(). See the following issue for this: http://framework.zend.com/issues/browse/ZF-2723 For now, in your REST server class, you can access raw POST data with the PHP input stream, like this: $body = file_get_contents('php://input'); If someone posts binary data (or any other kind of data, for that matter), you can use this to get the raw value of the POST. -- Ben Ramsey http://benramsey.com/ |
|
|
Re: Question for Zend_Rest_Client/Server-- Georgi Sokolov <joro@...> wrote
(on Wednesday, 12 March 2008, 04:55 PM +0200): > Is there an easy way to send binary data over POST to a > Zend_Rest_Server? I didn't see that kind of example on the documentation > but I need to send binary data(image) to a REST service? Typically, if you're sending it via post, you encode it to base64 -- but it will depend on the service you're posting to. -- Matthew Weier O'Phinney PHP Developer | matthew@... Zend - The PHP Company | http://www.zend.com/ |
|
|
Re: Question for Zend_Rest_Client/ServerBen Ramsey schreef:
> On 3/12/08 10:55 AM, Georgi Sokolov wrote: >> Is there an easy way to send binary data over POST to a >> Zend_Rest_Server? I didn't see that kind of example on the documentation >> but I need to send binary data(image) to a REST service? > > In version 1.5 of the Zend Framework, you'll be able to easily access > the raw POST data from a controller with > $this->getRequest()->getRawBody(). See the following issue for this: > > http://framework.zend.com/issues/browse/ZF-2723 > > For now, in your REST server class, you can access raw POST data with > the PHP input stream, like this: > > $body = file_get_contents('php://input'); > > If someone posts binary data (or any other kind of data, for that > matter), you can use this to get the raw value of the POST. > it to the REST server? This way you don't have to wait for version 1.5 of the ZFW to come out. -- Isaak Malik Web Developer isooik@... |
|
|
Re: Question for Zend_Rest_Client/ServerOn 3/12/08 11:22 AM, Isaak Malik wrote:
> Ben Ramsey schreef: >> On 3/12/08 10:55 AM, Georgi Sokolov wrote: >>> Is there an easy way to send binary data over POST to a >>> Zend_Rest_Server? I didn't see that kind of example on the documentation >>> but I need to send binary data(image) to a REST service? >> >> In version 1.5 of the Zend Framework, you'll be able to easily access >> the raw POST data from a controller with >> $this->getRequest()->getRawBody(). See the following issue for this: >> >> http://framework.zend.com/issues/browse/ZF-2723 >> >> For now, in your REST server class, you can access raw POST data with >> the PHP input stream, like this: >> >> $body = file_get_contents('php://input'); >> >> If someone posts binary data (or any other kind of data, for that >> matter), you can use this to get the raw value of the POST. >> > Or why not convert the binary code with base64_encode() before sending > it to the REST server? This way you don't have to wait for version 1.5 > of the ZFW to come out. > The getRawBody() method in version 1.5 doesn't specifically deal with binary data. It gets the full entity body of the HTTP request regardless of whether it is binary or base64-encoded. Yes, I would recommend base64-encoding your binary data before posting/putting it to any service, provided that service knows how to handle base64-encoded data. But my comment above still applies if the data is base64-encoded. You can use the php://input stream to get the full entity body from the request. -- Ben Ramsey http://benramsey.com/ |
| Free Forum Powered by Nabble | Forum Help |