orhun / rustypaste

A minimal file upload/pastebin service.
https://blog.orhun.dev/blazingly-fast-file-sharing
MIT License
760 stars 47 forks source link

Upload limit is ignored #336

Open tessus opened 3 weeks ago

tessus commented 3 weeks ago

I have set max_content_length = "50MB", but whenever I upload a file larger than 50MB, the entire file is uploaded and only then I get the error message that the limit is exceeded.

rpaste

https://github.com/user-attachments/assets/a4c88e80-980b-4614-89dd-a679aca1ab91

curl

https://github.com/user-attachments/assets/b427758e-57b1-4d94-ae15-3e14bc75de44

orhun commented 3 weeks ago

The middleware was implemented in #53 and yes, it turns out it is broken. I just reproduced this issue.

What would be the way of going forward with fixing this? Should we check HEAD requests, or do something in the middleware? Any ideas?

tessus commented 3 weeks ago

What would be the way of going forward with fixing this?

At one point I read a comment (but I am not sure in which repo or issue/discussion) that there is now a native way with the new versions of actix and/or actix-multipart which should render the middleware obsolete.

I've been looking for that comment frantically, but unfortunately haven't found it yet.

orhun commented 3 weeks ago

It would be the best way of moving forward if something like that exists. Custom implementations are not always infallible, like we saw in this case :D

tessus commented 3 weeks ago

I think I found it: https://stackoverflow.com/a/78399675

orhun commented 3 weeks ago

That's superb, can you try it out?

One thing to note that we probably won't be able to change this on the fly since it's configured while the App is constructed.

tessus commented 3 weeks ago

Not sure when I get to it, but yes, I would like to.