I am creating an PHP script that will merge multiple pdf documents uploaded to a couple rollbase records into one PDF document.
File Upload Users can upload a file which can be accessible through
this field, and optionally indexed as part of the search engine. You can
specify a maximum size for files from 128KB up to 2MB.
However, I can not access the uploaded files via the URL:
http://www.rollbase.com/prod1/servlet/File?dir=data&objDefId=' . $OBJDEF_ID . '&id=' . $recordId . '&name=' . $NAME . '&sessionId=' . $sessionID
When I view the URL in a web browser (after logging into rollbase), the uploaded file can be accessed, however the session id is not allowing access from our php web server.
I also tried logging in via REST API and using that session ID, but it does not work.The getDataField REST API also does appear to be working for uploaded files.
Do you have any suggestions on how I would be able to get access to uploaded files attached to Rollba
You can use REST API getBinaryData - please check Chapter 15 for more info.
I am trying to use the new REST API for setBinaryData using a PHP script, however, the uploaded file never opens when I view the record in Rollbase. A file gets uploaded, but it doesn't contain anything.
function UploadFile($url,$pdfString)
{
$session = curl_init($url);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $pdfString);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
print_r($response);
}
//assume $pdfString is a valid pdf converted into a string
$url = 'http://www.rollbase.com/rest/api/setBinaryData?sessionId='.$sessionID.'&id='.$rbid.'&fieldName=upload&fileName=MyFile.pdf&contentType=application/pdf';
UploadFile($url, $pdfString);
In the documentation it says:
"Request Body - Binary content of uploaded file"
Does this mean a string containing the binary content of the file?
Thank you
I will change this API to accept base-64 encoded values