I have data stored in a table that is base64 encoded binary file data. I am migrating this data from a version 7x install of BMC Remedy HelpDesk to Jira Service Desk. I would like to be able to send the binary file data directly to Jira via the attachment api. I really do not want to have to create the file locally on my filesystem first. Is there a way to feed the binary data to PHP's CURLFile?
Here is the example code I am using to post a local file via the api:
$process=curl_init($url);
$headers = array(
'X-Atlassian-Token: nocheck',
'Content-Type: multipart/form-data',
'Authorization: Basic XXX'
);
$cfile = new CURLFile("/path/to/file.jpg");
$cfile->setPostFilename("uploaded.jpg");
$data = array('file'=>$cfile);
curl_setopt_array(
$process,
array(
CURLOPT_POST=>true,
CURLOPT_VERBOSE=>1,
CURLOPT_POSTFIELDS=>$data,
CURLOPT_SSL_VERIFYHOST=> 0,
CURLOPT_SSL_VERIFYPEER=> 0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HEADER=>false,
CURLOPT_HTTPHEADER=> $headers
)
);
$result=curl_exec($process);
$ch_error = curl_error($process);
if ($ch_error) {
print "cURL Error: " . $ch_error;
} else {
print "\n" . $result . "\n";
}
curl_close($process);