title: php CURFILE binary data from database
body: <p>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?</p>
  
  <p>Here is the example code I am using to post a local file via the api:</p>
  
  <pre><code>$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-&gt;setPostFilename("uploaded.jpg");
  $data = array('file'=&gt;$cfile);
  
  curl_setopt_array(
    $process,
    array(
      CURLOPT_POST=&gt;true,
      CURLOPT_VERBOSE=&gt;1,
      CURLOPT_POSTFIELDS=&gt;$data,
      CURLOPT_SSL_VERIFYHOST=&gt; 0,
      CURLOPT_SSL_VERIFYPEER=&gt; 0,
      CURLOPT_RETURNTRANSFER=&gt;true,
      CURLOPT_HEADER=&gt;false,
      CURLOPT_HTTPHEADER=&gt; $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);
  </code></pre>