You are not logged in.
Pages: 1
Hi,
I hope this one will be easier, I'm using interface based web services and I need to send a PDF file to the client ( testing with google chrome ) I have this code on place :
procedure GetReport( idReport:Integer );
var
context: TServiceRunningContext;
begin
context := CurrentServiceContext;
context.Request.Call.OutHead := HEADER_CONTENT_TYPE + HTTP_RESP_STATICFILE;
context.Request.Call.OutBody := './reports/January.pdf';
context.Request.Call.OutStatus := 200;
end;
The former code is giving the following answer on the browser :
Server Error 404: Not Found
I don't know if this is the right way to serve files, because the procedure gets executed (already tried with function instead) but the file is not arriving to the browser, I looked at the sample 09 Http Api Web Server but the sample code isn't for interface based web services, may be it is not posible?
Offline
Thank you Arnaud,
If anybody ever needs to do this the working code is as follows :
function TServiceCustomers.GetReport(idReport: Integer): TServiceCustomAnswer;
var
reportFileName: RawUTF8;
begin
// some custom logic to locate the right file
result.Header := HEADER_CONTENT_TYPE + HTTP_RESP_STATICFILE;
result.Content:= reportFileName;
end;
Regards
Offline
Pages: 1