CircleOfNice / CiRestClientBundle

Mapper for PHP internal curl library
GNU General Public License v3.0
57 stars 20 forks source link

File upload POST request #36

Open aschmidt1976 opened 8 years ago

aschmidt1976 commented 8 years ago

Hi, I need to send file data from a Symfony2 web to an external REST API Resource (Gallery3 REST API). I absolutely do net get it how to embed files in a POST request. Is it possible with CiRestClientBundle? If yes, please update the documentation. Would be nice if there was a code example. For me, it's not clear what "somePayload" should look like in case of file upload.

What I already have is a working POST request without files:

$response = $restClient->post(
  'http://192.168.xxx.xxx/rest/item/1',
  'entity={"type":"album","name":"My new photo album","title":"My new photo album"}',
  array(
    CURLOPT_HTTPHEADER => array('X-Gallery-Request-Method: post', 'X-Gallery-Request-Key: '.urlencode($authToken)),
  )
);
TobiasHauck commented 8 years ago

Hey, thanks for reporting and sorry for being so late.

Actually it's not possible, but we should support it as file uploads are daily business. May you be so kind to work on that issue and open a PR? Would be great ;)