php - Post a blob using Guzzle -
is possible post blob using guzzle? methods i've been able find using @filename upload local file. file stored blob in mysql database , upload api post field without redundancy of saving blob disk (and permissions/path issues come it), uploading @filename, , unlinking file. here code have working blob. need 'file' field save data blob.
$data = array( 'first_name' => $fname, 'last_name' => $lname, 'email' => $email, 'partner_key' => 'qwerty', 'secret_key' => 'qwerty', 'file' => $fileblob ); $curl = new \guzzlehttp\client(); return $curl->post('https://www.api.com',['verify'=>false,'body'=>$data])
the goal being replace existing curl code using guzzle:
'file' => "@".$localfile.";type=".mime_content_type($localfile)
i found solution. helps others in future:
$data = array( 'first_name' => $fname, 'last_name' => $lname, 'email' => $email, 'partner_key' => 'qwerty', 'secret_key' => 'qwerty', 'file' => new \guzzlehttp\post\postfile('filename', $fileblob) ); $curl = new \guzzlehttp\client(); return $curl->post('https://www.api.com',['verify'=>false,'body'=>$data])
Comments
Post a Comment