question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using the library from the file-protocol possible?

See original GitHub issue

This library is awesome and works pretty good!

Here’s one thing, though (I don’t know, if this can get solved using wasm at all):

Since mediainfo uses fetch to load data, I’m unable to run it from the file:// protocol. I tried to polyfill `fetch, but get this error:

wasm streaming compile failed: TypeError: Failed to execute ‘compile’ on ‘WebAssembly’: An argument must be provided, which must be a Response or Promise<Response> object

Any hint, if it is even possible to use mediainfo.js from the file://protocol?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tiptroniccommented, Mar 27, 2020

@buzz @JeromeMartinez

Just for completeness sake: Overwriting fetch with a promisified XMLHttpRequest does the job pretty good. For me it now works on all required browsers (and also on the file:// protocol). Here’s the quick code (it just emulates fetch’s request returning a promised ‘arraybuffer’ ):

window.fetch = ( ...inParm ) => {
    const path = inParm[ 0 ];
    return new Promise( function( resolve, reject ) {
        const req = new XMLHttpRequest();
        req.withCredentials = true; // should be default anyway
        req.responseType = 'arraybuffer';

        req.addEventListener( 'load', () => {
            resolve( {
                ok: true,
                arrayBuffer: () => Promise.resolve( req.response )
            } );
        } );

        [ 'abort', 'error' ].forEach( ( evt ) => { req.addEventListener( evt, ( error ) => { reject( error ) } ) } );
        req.open( 'GET', path );
        req.send();
    } )
}

Thanks again for your kind help!

0reactions
buzzcommented, Apr 7, 2020

Closing issue as it seems to be resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Limitations of the "file" protocol - Brython documentation
With this protocol, it is always possible to import the modules in the standard library if the file brython_stdlib.js is loaded in the...
Read more >
file:// protocol not available · Issue #2732 · psf/requests - GitHub
The reason we don't support the file:// protocol is because requests is a HTTP library. Our core purpose is to do HTTP: anything...
Read more >
File Transfer Protocol Library
This library supports active and passive mode file transfers, firewall compatibility options, proxy servers and secure file transfers using the standard SSL/TLS ...
Read more >
file Protocol - Microsoft Learn
The following sample demonstrates four ways to use the File protocol. Copy. //Specifying a drive and a file name.
Read more >
Is there a uniform python library to transfer files using different ...
Is there a uniform python library to transfer files using different protocols ... I know there is ftplib for ftp, shutil for local...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found