private function createUploadHandle($url, $upload_file)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
// send file
curl_setopt($ch, CURLOPT_POST, true);
if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5) {
$attachments = realpath($upload_file);
$filename = basename($upload_file);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@' . $attachments . ';filename=' . $filename));
$this->log->addDebug('using legacy file upload');
} else {
// CURLFile require PHP > 5.5
$attachments = new \CURLFile(realpath($upload_file));
$attachments->setPostFilename(basename($upload_file));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => $attachments));
$this->log->addDebug('using CURLFile=' . var_export($attachments, true));
}
$this->authorization($ch);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*', 'Content-Type: multipart/form-data', 'X-Atlassian-Token: nocheck'));
curl_setopt($ch, CURLOPT_VERBOSE, $this->getConfiguration()->isCurlOptVerbose());
$this->log->addDebug('Curl exec=' . $url);
return $ch;
}