My question applies to Business Central.
I have got a PDF file stored in my database. I want to store the file somewhere (preferably same domain to prevent CORS errors), so it will be accessible from my javascript code (part of my addin control).
I tried a custom API, but I didn't find a way to build the response with the content of my file. It would be great if it could work that way. Here is the code snippet:
procedure Get(): HttpResponseMessage
var
OutStr: OutStream;
Response: HttpResponseMessage;
begin
Rec.Data.CreateOutStream(OutStr);
Response.Headers.Clear();
Response.Headers.Add('Content-Type', 'application/pdf');
Response.Headers.Add('Content-Disposition', 'inline; filename="Invoice.pdf"');
Response.Body(OutStr); // <--- No way to set the body content!
exit(Response);
end;
If it can't be done that way, how can I achieve this?