starlette icon indicating copy to clipboard operation
starlette copied to clipboard

feat: Optional max_file_size for parsing form files

Open khadrawy opened this issue 1 year ago • 6 comments

Summary

Limiting the size of file being uploaded in case the storage is limited or some business logic can't handle certain size.

Checklist

  • [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • [x] I've updated the documentation accordingly.

khadrawy avatar Oct 06 '24 04:10 khadrawy

If we instead make the max_part_size configurable, would that already be good enough here?

Kludex avatar Dec 03 '24 07:12 Kludex

If we instead make the max_part_size configurable, would that already be good enough here?

But from what I see here is that this is only applied to non file parts.

khadrawy avatar Dec 03 '24 10:12 khadrawy

If we instead make the max_part_size configurable, would that already be good enough here?

But from what I see here is that this is only applied to non file parts.

Hmmm... Does it make sense to be only on non file parts tho? 🤔

Kludex avatar Dec 03 '24 11:12 Kludex

@Kludex I think we need different limits for parts vs files. As files are spooled, we could allow larger size but for parts we want to have a stricter limit as it is stored in memory. I can re-work the PR to make it configurable for both.

khadrawy avatar Dec 03 '24 11:12 khadrawy

@Kludex what do you think about making all of limits configurable? https://github.com/encode/starlette/pull/2798/files I see that you are going to rename the max_file_size here https://github.com/encode/starlette/pull/2780 I can adjust naming if we can go forward with making all of the size limits configurable.

khadrawy avatar Dec 15 '24 07:12 khadrawy

We can make the limits configurable. We just need to adjust the naming, yep.

Let's start by making the spool one configurable, and then we add 1 by one. 🙏

Can you help?

Kludex avatar Feb 22 '25 13:02 Kludex