I have a Delphi server that I can obtain files from, for which I use the ROBinaryMemoryStream when I’m using a Delphi client, but what would be the correct choice for javascript, as that’s not an option? I’ve got a basic js client working now, but want to request a PDF file (it’s actually a report, created by reportbuilder by the server) to show in the browser. Is it as simple as using a json message (I’m currently using bin message) and if so, is there any sample of such for me to look at?
Thanks
Hi,
As I understand, the main issue that you can’t specify content type for received file?
these are several ways how to specify content type.
- use GetDispatchInfo. here you can set aTransport.ContentType for specific method:
if aMessage.MessageName = 'GetReport' then
(aTransport as IROHTTPTransport).ContentType := id_ContentType_application_pdf;
- Using OnCustomResponseEvent in a ROSDK Server. After processing, you can use
aResponse.ContentType := id_ContentType_application_pdf;
- use TROHTTPFileDispatcher for receiving pre-generated file. by default, we use
RegisterContentTypeForExtension('.pdf', id_ContentType_application_pdf);
- use HttpAPI and TROHttpApiResult. here you also can specify content type:
[ROServiceMethod]
[ROCustom('HttpApiPath', 'test')]
function TestMethod(): Binary;
...
function TMyService.TestMethod(): Binary;
begin
Result := TROHttpApiResult.Create(HTTP_200_code, id_ContentType_application_pdf,'report.pdf',false);
Result.LoadFromFile('report.pdf');
end;
Thanks Eugene, I will investigate those suggestions. Actually, the main issue is this is the first time I’ve used JavaScript, so it’s all a new fun learning curve
As an aside, is the only way to get any DA updates for JS by downloading the windows installer? Just checking as I’m developing on a Mac but boot up a windows vm, just to install to then grab the script file.
Hi,
We ship Data Abstract for JavaScript
as a windows installer only.