Giter VIP home page Giter VIP logo

Comments (4)

weavejester avatar weavejester commented on July 3, 2024

Is there a way of reliably determining, for all browsers, whether the file has been omitted from the input, or whether a zero-byte file has been submitted?

from ring.

rutchkiwi avatar rutchkiwi commented on July 3, 2024

Hadn't thought about that, but it looks like that can be determined from the filename:

-----------------------------264040574727381079401146929549
Content-Disposition: form-data; name="image"; filename="zerobytes.png"
Content-Type: image/png


-----------------------------264040574727381079401146929549

VS

-----------------------------6155252271109589944108876070
Content-Disposition: form-data; name="image"; filename=""
Content-Type: application/octet-stream


-----------------------------6155252271109589944108876070

This behaviour is the same for Firefox, Chrome and Safari.

But going into the nitty grittys, I can't find a canonical reference for how you can determine this.
RFC2388 seems to say the filename is optional.

So I'd suggest to only nil it when the filename is empty?

from ring.

weavejester avatar weavejester commented on July 3, 2024

I suspect there isn't a foolproof way of determining this, so I think the current behavior of Ring will have to remain. However, what you could do is to make some additional middleware in your project to update zero-byte files to nil responses.

from ring.

rutchkiwi avatar rutchkiwi commented on July 3, 2024

ok thats fair! just wasted an hour on this, so thought i would ask about it to save someone else the time. But you're likely right in that it cant be 100% accurately determined.

Thanks for the quick reply!

from ring.

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.