I am using Buzz Browser for calling POST
method. I am receiving a file from client at one of the end point
.
$fileObj = $requestObject->files->get('image_data');
This is correct fileObject
. I have verified this using is_file()
method.
Now, I have to fire a Buzz Browser
post event using this file as parameter.
$headers = array('Content-Type'=>'multipart/form-data');
$url = $genericHost . $api; //A valid URL
$params = array('image_data' => $fileObj);//fileObj obtained above
Posting this info using buzzBrowser
$browser->post($url, $headers, $params);
And receiving it as-
$fileObj = $this->get('request')->files->get('image_data');
But, the final $fileObj
is NULL
.
I tried to dump the $this->get('request')->files
-
object(Symfony\Component\HttpFoundation\FileBag)#11 (1) {
["parameters":protected]=>
array(0) {
}
}
Means no file is there. What is wrong in my approach?
Edit:1
After debugging more, I found that file object is being sent as normal parameters:
["request"]=>
object(Symfony\Component\HttpFoundation\ParameterBag)#7 (1) {
["parameters":protected]=>
array(1) {
["image_data"]=>
string(14) "/tmp/php6QLezs"
}
}
The header of the request is:
["headers"]=>
object(Symfony\Component\HttpFoundation\HeaderBag)#13 (2) {
["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)
}
}