#1 2024-10-27 15:48:43

hicham_taybi
Member
Registered: 2024-10-27
Posts: 10

open pdf files in browsers of client without downloading them

Hello
How can I create a service with mormot2 to allow the client to open pdf files that are on the server in their browsers without downloading them.
Thank you

Offline

#2 2024-10-27 16:25:49

zen010101
Member
Registered: 2024-06-15
Posts: 66

Re: open pdf files in browsers of client without downloading them

Content-Type is set to application/pdf, and Content-Disposition is set to inline, which tells the browser that the file should be opened directly in the browser rather than downloading it.

Offline

#3 2024-10-27 16:36:31

hicham_taybi
Member
Registered: 2024-10-27
Posts: 10

Re: open pdf files in browsers of client without downloading them

Thank you for your answer,
I am a deputant in Mormot
How can I do this
Thank you

Offline

#4 2024-10-27 16:39:42

hicham_taybi
Member
Registered: 2024-10-27
Posts: 10

Re: open pdf files in browsers of client without downloading them

I have this code to download
function TExampleService.DownloadFile(const FileName: RawUTF8): RawByteString;
var
  FileStream: TFileStream;
begin
  try
    FileStream := TFileStream.Create(UTF8ToString(FileName), fmOpenRead or fmShareDenyNone);
    try
      SetLength(Result, FileStream.Size);
      FileStream.ReadBuffer(Pointer(Result)^, FileStream.Size);
    finally
      FileStream.Free;
    end;
  except
    Result := '';
  end;
end;

Offline

#5 2024-10-27 16:52:31

zen010101
Member
Registered: 2024-06-15
Posts: 66

Re: open pdf files in browsers of client without downloading them

Offline

#6 2024-10-29 12:28:18

hicham_taybi
Member
Registered: 2024-10-27
Posts: 10

Re: open pdf files in browsers of client without downloading them

Thank you for your answer

Offline

Board footer

Powered by FluxBB