Uploaded images and videos keep getting bigger—how should file upload be designed so it doesn't overwhelm the system?
File upload is often treated as one button's worth of work, yet the real problems almost never come from the button itself. Images and videos travel from a user's phone through five stages—transfer, storage, processing, access and cleanup. Any stage built on a "get it working first" basis will eventually surface as slow loading, failed uploads, unexpected bills or files leaking out through external links.
Our default recommendation: compress lossily on the client while keeping an original-image option; upload files directly to object storage with temporary credentials; let the business server only issue credentials, validate metadata and receive callbacks; push thumbnails and video transcoding into an asynchronous queue; serve all files through short-lived signed URLs with role checks; and configure lifecycle rules to clean storage regularly. If the system is internal-only and handles a few hundred PDFs a month, this design is overkill—an ordinary form upload with private storage and regular backups is enough. Which tier fits depends on file size distribution, upload peaks, access scope and retention requirements, not on which technology the team knows best.
Why these problems clustered in the past two years
Three changes stacked on top of each other. Phone main cameras moved from 12 megapixels to 48 and beyond, so a single original photo easily exceeds 5 MB; short video became the default way to communicate, and one minute of 1080p footage is often over a hundred MB; meanwhile instant messaging trained users to expect instant progress, with no tolerance for starting over on a weak network.
Backends, however, were often designed for early traffic volumes: upload and business endpoints on the same server, files written to local disk with a path stored in the database, and access served by mapping that directory out through the web server. At a few hundred daily active users this works. At tens of thousands of daily actives and 200 MB videos, bandwidth and disk fail first, then backups, then security.
Four things to pin down before you start
File size distribution. You need the median, the 95th percentile and the maximum, not the average. The average is diluted by a mass of small files, while the 5% of large files are what actually break the system. Ask the business side for a real sample from the past month, or count from existing logs—far more reliable than guessing "a few megabytes".
Upload peaks. Concurrent uploaders multiplied by average file size gives your instantaneous bandwidth requirement. Event registration, homework submission and month-end expense filing cluster in time, and peaks can be a dozen times the daily average.
Access scope. Is a file publicly viewable, visible to logged-in users, visible only to its owner, or visible only to reviewers? This single decision determines whether a bucket is public, whether links must be signed and whether a CDN can be used. Many breaches happen not because someone broke in, but because a directory that should have been private was mounted as public static content.
Retention and deletion requirements. How long files are kept, who may delete them, whether deletion leaves a copy, and what happens when a user closes an account. This affects both cost and compliance. ID photos, contracts and medical records sitting for years at an accessible URL are a risk in themselves.
Six trade-offs along the pipeline
Compression: saving bandwidth, betting on quality
Client-side compression is the cheapest optimization. Re-encoding a photo at quality 0.7 to 0.8 usually cuts the file to 30–50% of the original with little visible difference. But the strategy must vary by purpose: social feed images, avatars and chat pictures can be compressed aggressively; scanned contracts, ID documents and receipts must keep text legible—better large than blurred. Whether to keep originals depends on whether the business needs re-editing or evidence; if so, store a separate copy rather than making every scenario carry the original's size.
Format compatibility also matters. iPhones shoot HEIC by default, and some Android devices and browsers cannot display it directly, so convert to JPEG or WebP on upload and preserve the correct rotation metadata—otherwise photos arrive sideways.
Transfer: forms for small files, multipart direct upload for large ones
A plain form upload is the fastest to build and suits files under 5 MB at modest volume. Its weakness is that a dropped connection on a weak network means re-sending the whole file, and the file stream passes through the business server.
Multipart upload splits a file into chunks, uploads each one, retries only the failed chunk, and has the server merge them at the end. This suits video, large archives and batch attachments. The next step is direct upload: the backend issues only a short-lived temporary credential, the client uploads straight to object storage with it, and the business server never touches the file stream—bandwidth and memory pressure move to the cloud storage side. Mini programs and apps both offer temporary credential mechanisms; scope the credential to write-only access on a specific directory and keep the validity to minutes.
Don't let business servers touch file streams
Proxying uploads looks "safer", but in practice it moves the cloud storage bandwidth pressure back onto your own servers and adds an extra write and forward. Except in special cases where content must be validated immediately (for example, virus scanning before a file can land on disk) or where files must enter an internal network first, let files go straight to storage and have the business server learn the result through callbacks.
Storage: object storage first, local disk only as cache
Local disk's problem is never capacity—it is expansion, backup, sharing across machines and migration. Object storage bills by usage, replicates by default, can sit behind a CDN, and makes lifecycle management straightforward. Store only metadata in the database: storage key, file size, actual type, hash, uploader, business owner and status. Do not put binary content into database fields; it slows down both backups and queries.
Processing: asynchronous, never make users wait for transcoding
Thumbnails, watermarks, video first frames and resolution transcoding take anywhere from seconds to minutes. The right approach: return immediately after a successful upload, queue the processing tasks, and let the frontend poll or receive push updates; failed processing must be retryable with a placeholder image as fallback. Making users wait on the upload page for transcoding noticeably raises abandonment, especially with long videos.
Access control: private buckets, signed links, role checks
Random file names are not access control. The right combination: buckets private by default; the backend issues access URLs valid for a few minutes based on login identity and business ownership; public content (product images, avatars, article illustrations) can go through a CDN, but buckets or directories must be separated by public and private at upload time. Hotlink protection reduces reuse by other sites but cannot stop someone with a link from forwarding it, so sensitive files cannot rely on it alone.
Costs and cleanup that are easy to overlook
Object storage bills usually have four parts: storage capacity, request count, outbound internet traffic, and image processing or transcoding. Capacity grows slowly; the latter two can run away. Common waste includes: the same image uploaded multiple times through different entry points; deleting only the database record while the file stays in the bucket; test environments holding copies of production data; and recycle bins without a retention limit that keep accumulating.
The fixes are not complicated: check file hashes on upload to deduplicate; delete via "mark as deleted plus delayed cleanup"; configure lifecycle rules on buckets so temporary files and recycle bins expire automatically; and periodically export storage inventories and reconcile them against business data to find orphan files with no owner.
Default plans for three typical scenarios
| Scenario | Typical files | Default plan | Extra items to confirm |
|---|---|---|---|
| Internal contracts and receipts | PDFs and scans, mostly 1–10 MB, low volume | Direct form upload to a private bucket, login plus role checks, retention per business rules | Whether stamped originals are needed, operation audit, bulk export |
| Community or e-commerce user content | Images 3–10 MB, videos tens to hundreds of MB, high volume | Client-side compression, multipart direct upload, async transcoding, public images via CDN | Moderation method, watermarking, monthly storage and traffic budget |
| Material submission in a mini program | ID photos and certificates, 1–5 MB, sensitive | Dedicated private bucket, encrypted storage, short-lived signing, access audit, automatic deletion on expiry | Minimum necessary collection scope, who may view, retention period |
Sizes in the table are common ranges only; the actual plan still has to follow your own business statistics.
How to check with your development vendor
- Ask for a file size distribution and peak estimate, stating the data source and time range—not a vague "probably not large".
- Ask exactly which path uploads take: how many servers they pass through, where files finally land, and whether interrupted uploads can resume.
- Ask for the pricing basis of the storage and traffic estimate: which unit prices, which usage volumes, and which items grow with users.
- Have them demonstrate live, with a different account, accessing someone else's file and show that it is refused; this is more convincing than reading a permission design document.
- Ask for weak-network test records, for example throttling to 500 KB/s while uploading a large video, and observe whether it breaks, whether it resumes, and whether the page shows a clear status.
- Ask for deletion and export plans: user account closure, contract expiry and mistakenly uploaded files—how each is handled and how quickly it takes effect.
How Boilingwater handles these projects
We build custom software, and an upload module appears in almost every project. We usually do not pick a tech stack first; instead we build a file inventory table with the business side: which file types exist, how large each is, who uploads, who views, and how long it is kept. Once that table is settled, the compression strategy, transfer method, storage form and permission model largely answer themselves.
On delivery we provide API documentation, storage and permission design notes, weak-network and concurrency test records, plus cleanup rules and an operations handover document. Cloud storage and traffic charges are billed directly to the client's own cloud account; we provide selection advice and capacity estimates, and the actual bill follows the cloud provider's real pricing—something worth stating clearly before the project starts.
Closing
The goal of file upload design is not "it uploads" but "it transfers, it can be found, it can be controlled, it can be deleted". Pin down four numbers first—size distribution, upload peak, access scope and retention period—then decide compression, transfer method and storage form; the plan becomes much clearer. If those four numbers are still undecided, taking inventory is usually a better use of time than writing code.
Additional Q&A
Should upload size have a limit?
Yes, but the limit should follow the business scenario rather than an arbitrary 10 MB. 20 MB is plenty for internal receipts, while user video may need 500 MB or more. Beyond the limit you also need clear messaging and failure handling, or users will simply retry over and over.
Must images always be stored as originals?
It depends on whether re-editing, evidence or printing is needed. For community display, no—the compressed version is enough; contracts, design files and medical images need the original kept separately from the display thumbnail.
Does using object storage make things secure?
No. Object storage solves capacity, durability and bandwidth; access control is still your job. Public buckets, excessively long signature validity and temporary credentials written into frontend code all defeat the storage's own security mechanisms.
What if a file has spread through external links?
First determine whether the file is public or private. For private files, tighten the bucket policy immediately and let already-issued links expire; for public files, hotlink protection, watermarking or reducing resolution can help, but downloaded copies cannot be recalled—which is why sensitive material should never be placed in a publicly readable location in the first place.
Sources note
The technical recommendations here come from our experience delivering custom projects. Object storage billing items, lifecycle rules and temporary credential mechanisms follow the general descriptions in major cloud providers' public documentation; actual prices, quotas and regional differences should be checked on the provider's own pages. Security requirements for personal information processing follow the minimum-necessary and security-safeguard principles of the Personal Information Protection Law of the People's Republic of China; specific compliance judgments should be confirmed by legal counsel in the context of the business.