ATTACHMENT WITH CATS CANDIDATE UPLOADING BROKEN IMAGE

17 views
Skip to first unread message

Ahsan Hussain

unread,
Sep 29, 2016, 1:50:38 PM9/29/16
to CATS API
Hi,

I'm trying to attach image to candidate record by using following code in laravel, but the images are getting uploaded brokenly, please let me know where i'm going wrong and also let me know if there is any library of catsone for laravel.

Code:



$imageName = time().'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path('images'), $imageName);
$imageName = realpath(public_path('images') . '/1475160618.png');

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.catsone.com/v3/candidates/175294227/attachments?filename=1122.png",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => 'data:image/png;base64,'.base64_encode(file_get_contents($imageName)),
CURLOPT_HTTPHEADER => array(
"authorization: Token 3***********************************3e",
"cache-control: no-cache",
"content-type: application/octet-stream",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
dd($err);
} else {
dd($response);
}


Above is my code i'm using to add an attachment.

Message has been deleted

Ahsan Hussain

unread,
Sep 29, 2016, 1:52:40 PM9/29/16
to CATS API
I'm using V3 of cats and its document link i'm following is : https://api.catsone.com/v3/docs/#candidates-upload-an-attachment
Reply all
Reply to author
Forward
0 new messages