- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWebAPI.Download.pas
More file actions
Latest commit
25 lines (20 loc) · 733 Bytes
/
Copy pathWebAPI.Download.pas
File metadata and controls
25 lines (20 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
unit WebAPI.Download;
interface
uses WebAPI, WebAPI.Blob;
procedureDownloadContent(fileName : String; blob : JBlob;
mimeType : String = 'application/octet-stream');
implementation
procedureDownloadContent(fileName : String; blob : JBlob;
mimeType : String = 'application/octet-stream');
begin
if Window.navigator.msSaveOrOpenBlob then
Window.navigator.msSaveBlob(blob, fileName)
elsebegin
var elem := Document.createElement('a');
elem.href := Window.URL.createObjectURL(blob);
elem.download := fileName;
Document.body.appendChild(elem);
elem.click();
Document.body.removeChild(elem);
end;
end;