curl_file_create creates a CURLFile. I need to create an equivalent object in java (possibly using HttpUrlConnection).
Here is the background:
I am trying to POST to a REST service hosted by a medical record system. The MIME type expected by the service is "multipart/form." I am assuming this is a documentation typo and they mean "multipart/form-data"
The call takes a few POST params, one of which is "attachmentcontents". Basically I have to supply the contents of my file that I want to upload to this param. How would I do this?
Now, when I try the following using CURL, I do succeed in uploading the attachment:
$object = array(
'Content-Type' => 'multipart/form',
'documentsubclass' => 'MEDICALRECORD_GROWTHCHART',
'departmentid' => <departmentId>,
'appointmentid' => <appointmentId>,
'attachmentcontents' => function_exists('curl_file_create') ? curl_file_create($file) : "@{$file}"
);
$result = $this->call("{practiceid}/patients/{$patientId}/documents", $object, 'XPOST');
In other words, the server accepts as "attachmentcontents," a CURL file object. I am thinking that if I can create and equivalent object in java, I would be out of the woods. How do I do so? Alternately, what is the equivalent of a CURL file object in java?