I want to upload an image to a external web service using Lumen + Guzzle 6. The external web service does not accept "base64-encoding" the image to be sent. Only the image file is accepted as such.
But I still get an error that the image could not be found or rather Guzzle sent the request without the image, although the function file_exists() could find it.
If I work with cURL-command-line on the console, it worked fine for me:
curl -v --user "username:password" ...
Thank you very much for every hints, why Lumen & Guzzle6 can't do it.
Here a bit of the code:
$filename_with_path = storage_path( 'app/pics/') . $file_name; $fileContent = File::get( $filename_with_path ); $mime_type = File::mimeType( $filename_with_path ); $this->guzzle_client = null; $this->guzzle_client = new Client( [ 'auth' => [ 'username', 'password' ], 'multipart' => [ [ 'name' => $file_name, 'filename' => $file_name, 'contents' => $fileContent, 'mime-type' => $mime_type, 'headers' => [ 'Content-Type' => $mime_type ] ], ], ] ); $this->response = $this->guzzle_client->request( 'PUT', $uri.$endpoint );