IW 15.5.10 Sendfile

<< Click to Display Table of Contents >>

Navigation:  Forum >

IW 15.5.10 Sendfile

Forum link

 

 

 


 

05-13-2024, 12:33 PM:

 

Hi,

 

After installing Delphi 12 Version 29.0.51511.6924 and IW 15.5.10

 

I has written a csv file like this: 

 

  { Create file }

 

  xFileName:=UserSession.UserId + '_1' + ExtractFileName('SaveAs') + '.csv';

 

  xPath:=gServerController.ContentPath  + 'Files\XIBFiles\' + xFileName;

 

  UserSession.ViewThisFile:=xPath;

 

  DeleteFile(UserSession.ViewThisFile);

 

  ZnfStreamW := TStreamWriter.Create(UserSession.ViewThisFile, False, TEncoding.Default);

 

.....

 

.....

 

.....

 

      ZnfStreamW.WriteLine(Line);

 

      dm.FDQrySaveAs.Next;

 

    end;

 

    dm.FDQrySaveAs.Close;

 

    WebApplication.SendFile(UserSession.ViewThisFile, False, '', ExtractFileName(UserSession.ViewThisFile));

 

  finally

 

    FreeAndNil(ZnfStreamW);    { Close and Free the writer }

 

  end;

 

This has worked perfectly before, but now the file is mysterious converted to a html fil

 

 

 

<!DOCTYPE HTML>

 

<html lang="en">

 

<head>

 

<meta charset="utf-8">

 

<title>XIB - Web Watch Dog: WWD (OpusCapita Solutions)</title>

 

<meta name="generator" content="IntraWeb v15.5.10 Serial 202440434">

 

<link href="/wwd/isapixibwwd.dll/$/css/IWBase__2933165573.css" rel="stylesheet">

 

<script nonce="yIJCVKoI+fDI9a5EoWWulrCEZwY">

 

var GURLBase="/wwd/isapixibwwd.dll/$/", GAppID="AeUrkFJfeLMC7BviU77qNcKmFGq", GTrackID=12

 

function doOnReady(f){

 

  var d = document

 

  if (d.readyState!="loading") f()

 

  else if (d.addEventListener) d.addEventListener("DOMContentLoaded", f)

 

  else d.attachEvent("onreadystatechange", function(){if (d.readyState=="complete") f()

 

}

 

</script>

 

<script src="/wwd/isapixibwwd.dll/$/js/IWLib__1925002372.js"></script>

 

<script src="/wwd/isapixibwwd.dll/$/js/IWBase__702901585.js"></script>

 

<script src="/wwd/isapixibwwd.dll/$/js/IWGecko__3425527816.js"></script>

 

<script nonce="yIJCVKoI+fDI9a5EoWWulrCEZwY">

 

 

 


 

05-13-2024, 09:17 PM:

 

>> WebApplication.SendFile(UserSession.ViewThisFile, False, '', ExtractFileName(UserSession.ViewThisFile));

 

It's possible you need to add the mime type in the 3rd parameter instead of the empty string.

 

 

 


 

05-15-2024, 08:35 AM:

 

(05-13-2024, 09:17 PM)MJS@mjs.us Wrote: [ -> ]>>    WebApplication.SendFile(UserSession.ViewThisFile, False, '', ExtractFileName(UserSession.ViewThisFile));

 

It's possible you need to add the mime type in the 3rd parameter instead of the empty string.

 

What is a mime type.

 

And remember SendFile has worked before IW 15.5.10

 

 

 


 

05-15-2024, 01:53 PM:

 

If it is the mime types then this may help to add some things to the servercontroller since everything is locked down now.

 

procedure TController.IWServerControllerBaseConfig(Sender: TObject);

 

begin

 

RestartExpiredSession := True;

 

TIWMimeTypes.RegisterType('.woff','application/x-font-woff', true);

 

TIWMimeTypes.RegisterType('.ttf', 'font/ttf', true);

 

TIWMimeTypes.RegisterType('.otf', 'font/otf', true);

 

TIWMimeTypes.RegisterType('.csv', 'text/csv', True);

 

//Needed to allow static html files to be servered up

 

TIWMimeTypes.RegisterType('.html', MIME_HTML, True);

 

TIWMimeTypes.RegisterType('.txt', MIME_TXT, True);

 

// RegisterContentType('application/xml');

 

end;

 

 

 


 

05-15-2024, 02:20 PM:

 

Hi,

 

Can you please explain what TIWMimeTypes.RegisterType does;

 

And what should I set in SendFile?

 

 

 


 

05-16-2024, 07:39 AM:

 

(05-15-2024, 01:53 PM)joelcc Wrote: [ -> ]If it is the mime types then this may help to add some things to the servercontroller since everything is locked down now.

 

procedure TController.IWServerControllerBaseConfig(Sender: TObject);

 

begin

 

  RestartExpiredSession := True;

 

  TIWMimeTypes.RegisterType('.woff','application/x-font-woff', true);

 

  TIWMimeTypes.RegisterType('.ttf', 'font/ttf', true);

 

  TIWMimeTypes.RegisterType('.otf', 'font/otf', true);

 

  TIWMimeTypes.RegisterType('.csv',  'text/csv', True);

 

  //Needed to allow static html files to be servered up

 

  TIWMimeTypes.RegisterType('.html', MIME_HTML, True);

 

  TIWMimeTypes.RegisterType('.txt', MIME_TXT, True);

 

//  RegisterContentType('application/xml');

 

end;

 

In what unit can I find TIWMimeTypes?

 

 

 


 

05-16-2024, 09:43 AM:

 

>>In what unit can I find TIWMimeTypes?

 

Under the IW install folder there is a help file named IW_Help.chm, this help file contains a lot of searchable and useful information.  For example, searching on TIWMimeTypes shows this (which includes the unit):

 

clip0010

 

Searching on SendFile shows this which explains the parameters:

 

clip0011

 

 

 


 

05-16-2024, 09:54 AM:

 

Hi,

 

Wonderful information. Thank you.

 

I also have to  change the order in witch I close my file stream. Before SendFille closed the stream, now I have to close  it before Sendfile