Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IW 15.5.10 Sendfile
#1
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">
Reply
#2
>> 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.
Reply
#3
(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
Reply
#4
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;
Reply
#5
Hi,

Can you please explain what TIWMimeTypes.RegisterType does;

And what should I set in SendFile?
Reply
#6
(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?
Reply
#7
>>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):

[Image: clip0010.png]

Searching on SendFile shows this which explains the parameters:

[Image: clip0011.png]
Reply
#8
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)