I benchmarked five approaches to implementing file infrastructure in a SaaS application. Three were executed and tested. The results were more interesting than I expected.

1. Why I ran this experiment

Most SaaS applications eventually need to handle user files.

At first, this looks like a storage problem. You need somewhere to upload files, store them and serve them back.

But as the application grows, more requirements appear:

  • Who owns each file?
  • Which user or workspace can access it?
  • How do permissions work?
  • How do you share files securely?
  • How do you handle expiration and deletion?
  • How do you audit access?
  • How do you prevent common security mistakes?

I built Filelayer around this problem: the application layer between a SaaS product and its underlying storage.

I wanted to understand what this abstraction actually saves, and whether it introduces meaningful trade-offs.

So I compared five approaches using the same functionality and security requirements.

I measured lines of code, security decisions, the 21 shared security attacks and review rounds.

2. Five approaches, three executed

I wrote five implementations:

  1. Raw S3
  2. Supabase Storage
  3. Convex
  4. Vercel Blob
  5. Filelayer

Not all five were executed. Vercel Blob and Convex were not compiled or run, so they are excluded from the quantitative comparison.

The three executed implementations were:

  • Filelayer
  • Supabase Storage
  • Manual S3

The quantitative averages compare Filelayer against the other two executed implementations.

3. The numbers

The results showed a substantial difference in the amount of application code required.

Compared with the average of the other two executed implementations, Filelayer required:

  • 4.1x fewer lines of code in the example implementation.
  • 2.9x fewer lines of code in the production implementation.

The library's own code isn't counted, the same way S3's or Supabase's isn't.

I also counted the security decisions developers had to make and get right.

  • 3.1x fewer security decision types.
  • 4.0x fewer security decision sites.

A type is a distinct class of security decision. A site is a place in the code where that decision has to be made correctly.

These numbers matter because every additional decision and every place where it must be implemented correctly creates another opportunity for mistakes.

4. The result that surprised me: manual S3 passed

The manual S3 implementation passed all 21 shared security attacks.

That's worth highlighting because it would be easy to assume that a dedicated abstraction automatically makes an implementation more secure.

It doesn't.

A careful implementation using S3 directly can be secure. The benchmark showed that clearly.

The potential value of Filelayer is reducing the amount of application-level file infrastructure developers need to build and maintain.

5. My own earlier version of Filelayer failed

There is another result I think is important to disclose.

Our own earlier version of Filelayer failed 3 attacks: 2 of the 21 shared ones and 1 of the 5 that only some implementations can express.

The failures were:

  • Cache replay.
  • A forged user identifier.
  • Stored XSS in the authenticated read path.

That's three vulnerabilities across 26 attacks.

I fixed the issues and continued testing.

I include this because a benchmark should expose weaknesses in your own product, not just demonstrate where it performs well.

6. What the benchmark actually tells us

This experiment does not prove that Filelayer is universally better than S3 or Supabase.

Manual S3 passed all 21 shared attacks. And for applications with simple storage requirements, using S3 directly may be entirely reasonable.

The distinction I wanted to explore is between storing files and managing user files.

Storage gives you a place for bytes.

A SaaS application also needs ownership, permissions, sharing, lifecycle management and secure delivery.

Those requirements create an application-level problem that developers otherwise have to solve themselves.

That's the problem Filelayer is designed to address.

7. When I wouldn't use Filelayer

I wouldn't use Filelayer for every file-related use case.

For example:

  • Simple file storage: S3 or R2 directly may be all you need.
  • An existing platform that already solves the problem: use what you already have if it meets your requirements.
  • Specialized media processing: a dedicated media infrastructure product may be a better fit.
  • Complete control: building your own layer can make sense if you have the resources and genuinely need that control.

Filelayer is intended for SaaS applications that need user-file infrastructure without rebuilding the same application-level concerns for every project.

8. Try it yourself

The code and benchmark results are public.

I'd be interested in seeing other developers reproduce the benchmark, challenge the methodology or find cases where the results differ.

The goal is to make the trade-offs visible, not to claim that one approach wins every situation.