Giter Site home page Giter Site logo

Comments (5)

imhoffd avatar imhoffd commented on April 28, 2024 1

@diachedelic Thanks for the insight. I think a separate HTTP server is a good way to implement this. I'd rather it be in Capacitor core, however. Perhaps all bridge communication could use the server (benchmarking needed).

from capacitor-plugins.

izeryab avatar izeryab commented on April 28, 2024 1

Don't think its perfect but somehow i managed to do it like this:

  fetch(jsoncall)
                    .then(res => res.blob()) // Gets the response and returns it as a blob
                    .then(blob => {
                        //saveAs(blob,fileName);
                        //let f = new File([blob],fileName);
                        var reader = new FileReader();//https://developer.mozilla.org/en-US/docs/Web/API/FileReader
                        reader.readAsDataURL(blob);
                        reader.onloadend = function () {
                            var base64data = reader.result;
                                capacitorFilesystem.Filesystem.writeFile({
                                    data: base64data as string,
                                    path: fileName,
                                    directory: capacitorFilesystem.Directory.Data
                                })

                        }
                    });

from capacitor-plugins.

diachedelic avatar diachedelic commented on April 28, 2024

I'd just like to note that I did try to implement this through the webview itself, and could not. See https://issuetracker.google.com/issues/36918490 and https://bugs.webkit.org/show_bug.cgi?id=179077

from capacitor-plugins.

diachedelic avatar diachedelic commented on April 28, 2024

Oh yeah, that would be great. capacitor-blob-writer would be even quicker for smaller payloads if it didn't make a bridge call before every request.

from capacitor-plugins.

HarelM avatar HarelM commented on April 28, 2024

Would be nice to also be able to download large files straight to the filesystem without the need "pass" through the webview (i.e. FileTransferPlugin capabilities).See my comment in 984 issue as this can crash the app due to out of memory.

from capacitor-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.