index.html 948 B

1234567891011121314151617181920212223242526272829
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>下载页面</title>
  5. <meta charset="UTF-8">
  6. </head>
  7. <body>
  8. <h1>下载文件</h1>
  9. <button onclick="downloadFile()">下载</button>
  10. <script>
  11. function downloadFile() {
  12. var xhr = new XMLHttpRequest();
  13. xhr.open('GET', 'https://dip.rxdptest.k5.bigtree.tech/api/dip-file/file/download?remotePath=xlsx/3f64366cf2dd2bc7198855a9584d31ab.xlsx', true);
  14. xhr.setRequestHeader('token', 'e95ba497940780fac84c4b04a065b685');
  15. xhr.responseType = 'blob';
  16. xhr.onload = function() {
  17. if (this.status === 200) {
  18. var blob = new Blob([this.response], {type: 'application/octet-stream'});
  19. var link = document.createElement('a');
  20. link.href = window.URL.createObjectURL(blob);
  21. link.download = 'file.xlsx';
  22. link.click();
  23. }
  24. };
  25. xhr.send();
  26. }
  27. </script>
  28. </body>
  29. </html>