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

self host mitm.html #231

Closed crapthings closed 3 years ago

crapthings commented 3 years ago

https://github.com/jimmywarting/StreamSaver.js/blob/master/StreamSaver.js#L31

mitm: 'https://jimmywarting.github.io/StreamSaver.js/mitm.html?version=2.0.0'

const fileStream = streamSaver.createWriteStream(`${filename}.zip`, {
  size: _.sumBy(downloads, 'length'), // optional downloading progress
  mitm: `${protocol}//cube-public.oss-cn-beijing.aliyuncs.com/cube-cdn/public/mitm.v2.0.0.html`,
});
JamesCorrigan commented 3 years ago

I'm having the same problem. are you using react?

jimmywarting commented 3 years ago

the protocol can never be anything else other than https b/c service worker is a power feature and requires the site to be secure (https), so you could as well hardcode the protocol to https also

only time it works with http is if the site is localhost or explicit whitelisted

guest271314 commented 3 years ago

only time it works with http is if the site is localhost or explicit whitelisted

mitm.html can be used from a minimal Chrome extension by specifying "web_accessible_resources" in manifest.json.

jimmywarting commented 3 years ago

Oh, right one more thing that is not how you are suppose to configure the mitm within createWriteStream option... you only do it once

import streamSaver from 'streamsaver'
streamSaver.mitm = 'https://cube-public.oss-cn-beijing.aliyuncs.com/cube-cdn/public/mitm.v2.0.0.html'