DEV Community

Byte Rivet
Byte Rivet

Posted on

How to Test File Upload Limits with Exact-Size Test Files

File upload testing often looks simple:

  1. Choose a file.
  2. Upload it.
  3. Confirm that it works.

But a single successful upload does not prove that the validation is reliable.

If an application accepts files up to 10 MB, the most useful test cases are not random files that are β€œaround 10 MB.” You need files that sit directly around the configured boundary.

For a decimal 10 MB limit, that may mean testing:

  • 9,999,999 bytes
  • 10,000,000 bytes
  • 10,000,001 bytes

These three files can reveal whether the application handles its upload limit correctly.

Why exact file size matters

Upload limits can be enforced at several different layers:

  • Browser-side JavaScript
  • Application server
  • Reverse proxy
  • Web server
  • API gateway
  • Cloud storage service
  • Database or object storage quota

These layers may not use the same limit or even the same measurement system.

For example, one part of the application may interpret 10 MB as 10,000,000 bytes, while another may treat it as 10 MiB, which equals 10,485,760 bytes.

I built ByteRivet to make this workflow easier.

That difference is large enough to produce inconsistent behavior.

A file may pass client-side validation but fail after the upload begins. It may also be accepted by the application but rejected by a proxy before reaching the server.

A basic boundary testing strategy

Assume your application has a maximum upload size of 10,000,000 bytes.

Create three files:


text
Below the limit: 9,999,999 bytes
At the limit:    10,000,000 bytes
Above the limit: 10,000,001 bytes
Enter fullscreen mode Exit fullscreen mode

Top comments (0)