Jump to content

Download file without extension defined (blank)


Fred Montier

Recommended Posts

Is there any way to download a file without defined extension (empty, just the name) ?

For some odd reason and integration to old equipment, a client is looking for this solution. That can be done in others HTTP servers. Works ok. But my client wants to use just uniGUI and not install another HTTP server just for this reason, in his cloudserver.
For instance this works in my server: (Link Removed. Solved).
Where "user", at the end of the URL is a text file without extension.

I found: In uniGUI 'application/octet-stream' is generic name for unknown types which currently is not allowed.

Look, it works with other servers.  I just need to do the proper way in uniGUI. Otherwise... do some tricks.

Thanks in advance.

 

Link to comment
Share on other sites

  • Fred Montier changed the title to Download file without extension defined (blank)

Hello,

You can try something like this...

//uses list
SysUtils, uIdCustomHTTPServer, uIdGlobal
procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
begin
  if (ARequestInfo.Document <> '') and (SysUtils.FileExists(ExtractFilePath(ParamStr(0)) + ARequestInfo.Document)) then
  begin
    AResponseInfo.ContentType:='application/octet-stream';
    AResponseInfo.ContentStream := TIdReadFileExclusiveStream.Create(ExtractFilePath(ParamStr(0)) + ARequestInfo.Document);
    Handled := True
  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...