1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. </head>
    8. <body>
    9. <script>
    10. //url转blob
    11. function urlToBlob() {
    12. let file_url =
    13. 'http://obdataplatform-test.oss-cn-shenzhen.aliyuncs.com/2020_07_10/391f56b9-f4bc-408b-868b-31ea0f8b1b47.hex'
    14. let xhr = new XMLHttpRequest();
    15. xhr.open("get", file_url, true);
    16. xhr.responseType = "blob";
    17. xhr.onload = function () {
    18. if (this.status == 200) {
    19. // if (callback) {
    20. // callback();
    21. console.log(this.response)
    22. const reader = new FileReader()
    23. reader.onload = function () {
    24. console.log('reader.result', reader.result)
    25. }
    26. reader.readAsText(this.response);
    27. }
    28. };
    29. xhr.send();
    30. }
    31. urlToBlob()
    32. </script>
    33. </body>
    34. </html>