![]() |
|
IW 15.5.10 Sendfile - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: IW 15.5.10 Sendfile (/thread-4139.html) |
IW 15.5.10 Sendfile - Mikael Nilsson - 05-13-2024 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"> RE: IW 15.5.10 Sendfile - MJS@mjs.us - 05-13-2024 >> 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. RE: IW 15.5.10 Sendfile - Mikael Nilsson - 05-15-2024 (05-13-2024, 09:17 PM)MJS@mjs.us Wrote: >> WebApplication.SendFile(UserSession.ViewThisFile, False, '', ExtractFileName(UserSession.ViewThisFile)); What is a mime type. And remember SendFile has worked before IW 15.5.10 RE: IW 15.5.10 Sendfile - joelcc - 05-15-2024 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; RE: IW 15.5.10 Sendfile - Mikael Nilsson - 05-15-2024 Hi, Can you please explain what TIWMimeTypes.RegisterType does; And what should I set in SendFile? RE: IW 15.5.10 Sendfile - Mikael Nilsson - 05-16-2024 (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. In what unit can I find TIWMimeTypes? RE: IW 15.5.10 Sendfile - MJS@mjs.us - 05-16-2024 >>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): ![]() Searching on SendFile shows this which explains the parameters:
RE: IW 15.5.10 Sendfile - Mikael Nilsson - 05-16-2024 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 |