Every line of 'angular download file on click' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
15 function download (file) { 16 const mime = file.type || 'text/plain'; 17 const type = `${mime};charset=utf-8`; 18 const filename = file.name || 'download.txt'; 19 20 const blob = new Blob([file.content], {type}); 21 saveAs(blob, filename); // shim this 22 }
164 private onDownload(e: Event) { 165 e.preventDefault(); 166 this.selector.close(); 167 168 this._fileService.download(this.model.file_info); 169 }
40 function startDownload(path, fileName) { 41 var anchor = $("#DownloadAnchor"); 42 anchor.attr("target", "_self"); 43 anchor.attr("href", path); 44 anchor.attr("download", fileName); 45 anchor[0].click(); 46 };
477 onDownloadFile (filename, href) { 478 479 let a = document.createElement('a') 480 481 a.download = filename 482 a.href = href 483 484 a.click() 485 }
22 download() { 23 var fileName = this.imageService.fileName; 24 this.embedService.embeddedCanvas.toBlob(function (blob) { 25 download(blob, fileName, 'image/png'); 26 }) 27 }
42 _triggerDownload () { 43 const archive = this.context.archive 44 const node = this._getNode() 45 const isLocal = this._isLocal() 46 let url = node.href 47 if (isLocal) { 48 url = archive.getDownloadLink(node.href) 49 } 50 if (url) { 51 this.refs.link.el.attr({ 52 'href': url 53 }) 54 this.refs.link.el.click() 55 } 56 }
86 export function download(url = "", showLoading = true) { 87 if (showLoading) wx.showLoading({title: '加载中',}); 88 return new Promise((resolve, reject) => { 89 wx.downloadFile({ 90 url: url, 91 success(res) { 92 resolve(res.tempFilePath); 93 }, 94 fail(res){ 95 reject(res); 96 }, 97 complete(){ 98 if (showLoading) wx.hideLoading(); 99 } 100 }) 101 102 }); 103 }
18 downloadFile() { 19 console.log("Loading data..."); 20 this.primeService.downloadFile((data) => { 21 var file = data.fileBase64; 22 console.log(file); 23 }); 24 }
45 function download() { 46 var url = $("input").text 47 $ui.toast("开始下载: " + url) 48 $ui.loading(true) 49 $http.download({ 50 url: url, 51 handler: function(resp) { 52 $ui.loading(false) 53 $share.sheet(resp.data) 54 } 55 }) 56 }
346 downloadItem() { 347 const file = this.selectedItems.firstObject as unknown as File; 348 // TODO: Make this a link that looks like a button 349 window.location.href = getHref(file.links.download!); 350 if (!this.canEdit) { 351 this.analytics.click('button', 'Quick Files - Download'); 352 } 353 }