jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.97k stars 413 forks source link

Any instruction on how to self host mitm? #242

Open 2niuhe opened 3 years ago

2niuhe commented 3 years ago

I use this package in an angular project, everything works fine in dev env.

I need to deploy to a production environment isolated from the Internet, the production environment cannot access github.io

I am new to javascript, and i have tried to clone the code and self host the mitm.html with a local python https server.

from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl

httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler)

httpd.socket = ssl.wrap_socket (httpd.socket, 
        keyfile="path/to/key.pem", 
        certfile='path/to/cert.pem', server_side=True)

httpd.serve_forever()

after exec the python script, i can open the https://localhost:4443/mitm.html in browser.

I also config the streamSaver.mitm='https://localhost:4443/mitm.html'. But when i try to write the fetch stream to disk, nothing happened.

Any help or instruction about self host mitm?

peachyclem commented 3 years ago

You need to copy over /mitm.html and /sw.js into your public folder and assign streamSaver.mitm = '/mitm.html'

You are most likely getting an error that sw.js is not loading.

guest271314 commented 2 years ago

If you are using a Python server locally aioquic and WebTransport can be used to stream content to local file system.

JounQin commented 2 years ago

The default mitm.html is not safe to use in Firefox. Maybe this should be documented better.

image

jimmywarting commented 2 years ago

Would you like to submit a PR?

JounQin commented 2 years ago

Would you like to submit a PR?

OK, I'll give a try.

miwels commented 1 year ago

I would like to reopen this conversation to ask if it's possible to bundle the 'mitm.html' file instead of accessing it through a URL.

I'm creating a library using StreamSaver and would like to store the 'mitm.html' file in my assets in order to load it in the library.

streamsaver.mitm = './assets/mitm.html or streamsaver.mitm = 'file://assets/mitm.html

Any idea if this is possible? Thanks