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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -