Coder Social home page Coder Social logo

Handling iframe upload errors about file-upload HOT 1 OPEN

jdkealy avatar jdkealy commented on August 20, 2024
Handling iframe upload errors

from file-upload.

Comments (1)

theophilusx avatar theophilusx commented on August 20, 2024

A lot will depend on the type of error you are talking about. The code I've done has little error checking (as you have discovered). Working from memory here, will need some time to look at this, which I just don't have right now.

There are really at least two levels of error you need to cater for. There are protocol type errors i.e. cannot connect to serrver, connection lost, server does not recognize request etc. These really need to be handled with iframe handlers. My code really only implements a handler for the completed case and does not check the status closely. However, the general form for these listners is the same. I think you just need to add one.

Then you need to handle the case where all the protocol stuff works, but the serrver detects an error in the data yuo have uploaded - for example, incorrect format or some other error generated when the server is processing the data you uploaded. In this case, I tend to use a json structure with a status value and in the case of an error status, an error message.

This approach gives more flexibility, but at the cost of some additional complexity as you need to now check for errors at two levels. If I had more time, I'd probably see how to amalgamate it so that we send back an error which is the same as a protcol error in form and we can then just have one error handling process.

Truth of the matter is I've found that cljs-ajax has been much easier and done everything I needed, so I've not used the direct iFrame approach much. My plan is to next look at using web sockets to do uploads which are large so that I can provide real-time progress feedback, which is nearly impossible to do well using the 'traditional' approaches. The problem with cljs-ajax is that it won't work if you must support older browsers. I don't need to as my audiences have been limited (corporate closed shop applications) were we can dictate the browser version.

I'll try to find time to look at this in the next few weeks.

from file-upload.

Related Issues (1)

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.