Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading from URL #5

Open
ff7man opened this issue Nov 24, 2023 · 0 comments
Open

Loading from URL #5

ff7man opened this issue Nov 24, 2023 · 0 comments

Comments

@ff7man
Copy link

ff7man commented Nov 24, 2023

In order to load from a URL I had to change how the binary was downloaded, instead of using blob I had to download as an arraybuffer and then convert to a blob. I'm not sure if this is caused by a recent change in Chrome.

var getFileBlob=function(e,t){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.addEventListener("load",function(){t(n.response)}),n.send()};

to

var getFileBlob=function(e,t){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="arraybuffer",n.addEventListener("load",function(){t(new Blob([n.response],{ type: "application/octet-stream" }))}),n.send()};

the files were hosted on a server with cors removed, here's how to do that in python

#!/usr/bin/env python3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
import sys

class CORSRequestHandler (SimpleHTTPRequestHandler):
    def end_headers (self):
        self.send_header('Access-Control-Allow-Origin', '*')
        SimpleHTTPRequestHandler.end_headers(self)

if __name__ == '__main__':
    test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)

File loading from a URL could really use a overhaul and show progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant