Giter Site home page Giter Site logo

Comments (9)

usar-naem avatar usar-naem commented on May 16, 2024

I would like to +1 this request. It should not rely only on the client filter. The server needs to reject files larger than the specified amount, and make sure the final size is the same as announced at the start. Filtering by extension is good too.

Currently the behavior for submitting a 20mb+ file is an empty file being created, and the server hanging indefinitely thereafter. The only way this is viable in a production environment is if you can force a maximum size with 100% certainty.

I would lend my hand, but I fear I may not be up to the task.

from socketio-file-upload.

vote539 avatar vote539 commented on May 16, 2024

Yeah, you're right. This feature should really be supported in this module. I'll look into it.

from socketio-file-upload.

vote539 avatar vote539 commented on May 16, 2024

My latest commit adds support for file size checking. Let me know if the API and such looks good to you. If it does then I'll go ahead and push it out to npm.

from socketio-file-upload.

usar-naem avatar usar-naem commented on May 16, 2024

Well it's not impenetrable, but the "saved" event is now rather inaccurately named. I would suggest adding an error code for straight up upload failure as well, and dropping the success flag. "Saved" should be reserved for success cases only, or renamed appropriately. Handling file rejection out of the "error" event seems fine to me.

from socketio-file-upload.

vote539 avatar vote539 commented on May 16, 2024

Well it's not impenetrable

Can you explain?

but the "saved" event is now rather inaccurately named. I would suggest adding an error code for straight up upload failure as well, and dropping the success flag. "Saved" should be reserved for success cases only, or renamed appropriately. Handling file rejection out of the "error" event seems fine to me.

The "error" event is fired when file upload is large. An empty file is always created on the filesystem, so it seems to me like "saved" is a fine event name. An application can always check for event.file.success for whether or not the save was successful. Renaming the event is not an option due to backwards compatibility, which I put as a high priority.

from socketio-file-upload.

usar-naem avatar usar-naem commented on May 16, 2024

By not impenetrable, I simply meant that it's not difficult to understand. :)

Are you sure you want an empty file to be created if the server intends to reject the upload? I think the logical behavior is that you want to stop the process as soon as you know that you don't want the file, so as not to even bother the file system with useless tasks.

EDIT: Oh, I understand. In an ideal world, you would be writing to the file one part at a time, not buffering it. Your api makes sense now.

from socketio-file-upload.

vote539 avatar vote539 commented on May 16, 2024

The client could tell the server ahead of time how big to make the file, and if the file exceeds the bounds then the server can ignore it. However, this depends on the client telling the truth about the size of the file, and if the client is telling the truth, then they won't even send a request to the server in the first place due to the client-side validation in 5ff8e73.

I'll run a few more manual tests and then push this out to npm. One of these days I'll need to set up automated testing for this module (or merge a pull request that does it). 😃

from socketio-file-upload.

pitambar avatar pitambar commented on May 16, 2024

thank you for implementing the requirement :)

from socketio-file-upload.

vote539 avatar vote539 commented on May 16, 2024

This change has been published to npm in versions 0.3.1 and higher.

from socketio-file-upload.

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.