I receive this message when I attempt to download a file using JQFileDownload:
... raised exception class EIWCGJQuery with message "The file can not be returned by server!".
This error occurs only after I open a TIWCGJQDialog by clicking a TIWCGJQButton with an async event.
Once I close the dialog and click on the TIWLink, . it attempts to execute this line from the DownLoadLinkedDocument procedure:
Self.fileDownload.DownloadFileName(strTo)
Circumstances:
I insert a TIWLink into my grid so that I have somewhere to click and download the file. This code shows the creation of the TIWLink component and setting the various properties:
<snip>
if not Assigned(Cell[Row,3].Control) then
begin
Cell[Row,3].Control := TIWLink.Create(Self);
TIWLink(Cell[Row,3].Control).Name := 'LinkedDocumentLink' + S2Snax.IntegerToString(ID);
end;
TIWLink(Cell[Row,3].Control).Caption := FileName;
TIWLink(Cell[Row,3].Control).Tag := ID;
TIWLink(Cell[Row,3].Control).OnAsyncClick := Self.ContactLinkedDocumentLinkAsyncClick;
<snip>
Here is the async click event code:
procedure TformContactEdit.ContactLinkedDocumentLinkAsyncClick(Sender: TObject; EventParams: TStringList);
begin
Self.DownLoadLinkedDocument(TIWLink(Sender).Text);
end;
Here is the procedure called from inside the async event:
procedure TformContactEdit.DownLoadLinkedDocument(Filename: String);
var
strFrom, strTo: String;
begin
strFrom := UserSession.SharedDocumentDirectory + S2Snax.IntegerToString(Self.ContactID) + PATHDELIM + Filename;
strTo := UserSession.UserTempDir + Filename;
CopyFile(PChar(strFrom), PChar(strTo), False);
if FileExists(strTo) then
Self.fileDownload.DownloadFileName(strTo)
else
WebApplication.ShowMessage('Error: Unable to locate file - ' + strTo);
end;