I use Buzz Browser to call a method POST. I get the file from the client in one of end point.
$fileObj = $requestObject->files->get('image_data');
This is correct fileObject. I checked this with a method is_file().
Now I need to fire the Buzz Browserpost event using this file as a parameter.
$headers = array('Content-Type'=>'multipart/form-data');
$url = $genericHost . $api;
$params = array('image_data' => $fileObj);
Publishing this information with buzzBrowser
$browser->post($url, $headers, $params);
And getting it like -
$fileObj = $this->get('request')->files->get('image_data');
But the final one $fileObjis NULL.
I tried to reset $this->get('request')->files-
object(Symfony\Component\HttpFoundation\FileBag)
["parameters":protected]=>
array(0) {
}
}
So the file is missing. What is wrong with my approach?
Edit: 1
After debugging more, I found that the object file is sent as normal parameters:
["request"]=>
object(Symfony\Component\HttpFoundation\ParameterBag)#7 (1) {
["parameters":protected]=>
array(1) {
["image_data"]=>
string(14) "/tmp/php6QLezs"
}
}
Request Header:
["headers"]=>
object(Symfony\Component\HttpFoundation\HeaderBag)
["headers":protected]=>
array(7) {
["content-type"]=>
array(1) {
[0]=>
string(70) "multipart/form-data; boundary=----------------------------1b3e33ff2ecb"
}
["content-length"]=>
array(1) {
[0]=>
string(3) "159"
}
["host"]=>
array(1) {
[0]=>
string(16) "host_name"
}
["accept"]=>
array(1) {
[0]=>
string(3) "*/*"
}
["x-php-ob-level"]=>
array(1) {
[0]=>
int(1)
}
}
source
share