Thursday, April 13, 2017

Headers get written to file after uploading with Guzzle

I'm trying to upload a csv file to a cloud storage using Laravel and Guzzle. The file does get successfully uploaded, but the problem is that for some reason the headers are written to the file along with the original content after the upload. That also happens when I upload the file through Postman. How can this be prevented and what is the correct way of sending such request ? Here's the snippet and the uploaded file content :

$res = $client->request('POST', $uri, [
                'headers'   => [
                                'Authorization'         => 'Bearer '. $egnyteToken,
                                'Content-Type'          => 'text/csv'
                            ],
                'multipart' => [
                            [
                                'name'     => $file->getClientOriginalName(),
                                'contents' => File::get($file),
                                'filename' => $file->getClientOriginalName(),
                            ]
                ]
            ]);

enter image description here



via user3102290

Advertisement