Imagine uploading a 2 GB video to cloud storage. The upload reaches 95%, your internet connection drops, and the entire process starts again from zero.
For users, this is frustrating. For developers, it represents wasted bandwidth, unnecessary requests, and a poor user experience.
A resumable file upload API can help solve this problem.
I'm the founder of MergeDrive, a multi-cloud storage project involving Google Drive and OneDrive. Upload reliability, storage availability, and managing multiple connected accounts are particularly relevant challenges in this problem space.
In this article, we'll explore how developers can design a reliable cloud storage file upload API.
What Is a Resumable File Upload?
A resumable file upload allows an interrupted file transfer to continue from a previously confirmed position instead of restarting the entire upload.
The process generally involves:
- Creating an upload session.
- Dividing the file into smaller chunks.
- Uploading those chunks.
- Tracking the data successfully received by the destination.
- Resuming from the confirmed position after an interruption.
- Finalizing the upload.
The key difference is that upload progress can survive certain network interruptions, provided the upload session and original file data remain available.
Traditional Uploads vs. Resumable Uploads
| Feature | Traditional single-request upload | Resumable upload |
|---|---|---|
| Transfer method | Entire file in one request | Multiple requests supported |
| Network interruption | Often requires restarting | Can resume an active session |
| Progress tracking | Usually request-based | Server-confirmed progress |
| Large file handling | More vulnerable to interruptions | Better suited to long transfers |
| Implementation | Simpler | More complex |
| Session management | Usually unnecessary | Required |
For small files, traditional uploads may be sufficient.
For large videos, documents, backups, and unreliable network connections, resumable uploads offer significant practical advantages.
Designing the Upload Architecture
A reliable file upload system can contain several independent components:
- Client application.
- File upload API.
- Upload job queue.
- Storage destination selector.
- Upload session manager.
- Provider-specific storage adapters.
- Upload status database.
A simplified architecture might look like this:
Client Application | Upload API | Upload Queue | Storage Destination Selector | Upload Session Manager | +-- Google Drive API | +-- Microsoft Graph API Separating these responsibilities makes it easier to manage failures, retries, scheduling, and different storage providers.
Step 1: Maintain Upload Session State
A resumable upload service needs to maintain information about each upload.
For example, a TypeScript model could look like this:
type UploadStatus = | "queued" | "uploading" | "paused" | "completed" | "failed"; interface UploadJob { id: string; accountId: string; fileName: string; totalBytes: number; confirmedBytes: number; provider: "google-drive" | "onedrive"; status: UploadStatus; priority: number; scheduledAt?: string; sessionExpiresAt?: string; } Persisting this metadata allows the application to recover upload state after a worker or application restart.
However, metadata alone is not enough. The original file data must also remain accessible to the upload worker.
Step 2: Split Large Files Into Chunks
Instead of loading an entire large file into memory, an application can process smaller portions.
Here is an illustrative browser-side chunk generator:
function* createChunks( file: Blob, chunkSize: number ) { if ( !Number.isSafeInteger(chunkSize) || chunkSize <= 0 ) { throw new Error("Invalid chunk size"); } for ( let start = 0; start < file.size; start += chunkSize ) { const end = Math.min( start + chunkSize, file.size ); yield { start, endExclusive: end, data: file.slice(start, end) }; } } This creates portions of the original file without requiring the entire file to be loaded into a single JavaScript buffer.
The appropriate chunk size depends on the destination provider and its upload requirements.
Server-side applications can use streams or controlled file reads instead.
Step 3: Resume From Server-Confirmed Progress
One important mistake to avoid is assuming that every byte sent by the client has been successfully stored by the destination.
Suppose a file upload is interrupted:
- Total file size: 1,000 MiB.
- Client attempted to send: 650 MiB.
- Cloud provider confirmed: 640 MiB.
The application should resume according to the provider's reported upload state, not the client's attempted progress.
Otherwise, the upload may skip missing data or submit incorrect byte ranges.
A simple progress calculation could look like this:
function getProgress( confirmedBytes: number, totalBytes: number ): number { if (totalBytes <= 0) return 0; return Math.min( 100, Math.max( 0, (confirmedBytes / totalBytes) * 100 ) ); } Only confirmed progress should be persisted as successfully uploaded data.
The application should mark a job as completed only after the provider confirms successful file creation or finalization.
Step 4: Handle Google Drive and OneDrive Differently
Although both providers support resumable file uploads, their underlying implementations differ.
Google Drive File Upload API
Google Drive supports resumable upload sessions.
The application creates a session and sends file content to the returned session URI.
An HTTP 308 response during the upload indicates that additional data is still required. The application can inspect the returned range information or query the session to determine where to continue.
Official documentation:
https://developers.google.com/workspace/drive/api/guides/manage-uploads
Microsoft OneDrive Upload API
OneDrive supports large file uploads through Microsoft Graph upload sessions.
The session provides an upload URL and expiration information. The application transfers file portions and uses the session's missing-range information to recover from interruptions.
Microsoft Graph also has specific chunk alignment requirements, including 320 KiB alignment for non-final fragments.
Official documentation:
https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
A unified cloud storage API can expose consistent upload states while keeping these provider-specific requirements inside separate adapters.
Step 5: Introduce a Priority File Upload Queue
Not every upload has the same urgency.
Consider a SaaS application processing:
- An urgent customer document.
- A large video upload.
- A scheduled backup.
- Multiple background file transfers.
A priority upload queue can help determine which jobs should be processed first.
Here is a simplified job selection function:
function getNextUpload( jobs: UploadJob[], now = Date.now() ): UploadJob | undefined { return jobs .filter(job => job.status === "queued" && ( !job.scheduledAt || Date.parse(job.scheduledAt) <= now ) ) .sort( (a, b) => b.priority - a.priority )[0]; } This example selects eligible jobs according to priority and scheduled execution time.
A production queue would also need to handle concurrent workers, atomic job claiming, retry limits, fairness, and worker failures.
Priority scheduling should not permanently prevent lower-priority jobs from completing.
Step 6: Select the Right Cloud Storage Destination
Multi-cloud applications introduce another challenge: deciding where a file should be uploaded.
Consider three connected cloud accounts:
| Cloud account | Available storage |
|---|---|
| Google Drive A | 2 GB |
| Google Drive B | 12 GB |
| OneDrive | 4 GB |
For a 6 GB upload, only Google Drive B has sufficient available capacity.
A smart upload service can evaluate:
- Available storage.
- User-defined account preferences.
- File size.
- Account permissions.
- Provider limitations.
- Concurrent upload reservations.
Remember that the combined available space across multiple accounts does not automatically become one physical storage quota.
Storage selection is also different from resumability. Switching to a different provider after an interrupted upload generally requires a new upload session.
Step 7: Handle Upload Failures Properly
Not every failed upload should be retried in the same way.
| Failure | Recommended response |
|---|---|
| Network interruption | Query session and resume |
| Rate limit | Respect retry instructions and back off |
| Temporary server error | Retry with bounded exponential backoff |
| Insufficient storage | Reevaluate destination or notify user |
| Expired upload session | Create a new session if appropriate |
| Permission denied | Request authorization or stop |
Before retrying an ambiguous failure near upload completion, check whether the file was already created.
This helps avoid accidentally creating duplicate files.
Upload session URLs should also be treated as sensitive credentials and kept out of application logs.
Step 8: Notify Applications About Upload Completion
For long-running file uploads, background processing can be more practical than holding an HTTP request open.
Applications can expose upload status through polling or application-level webhooks.
An illustrative completion event might look like this:
{ "event": "upload.completed", "uploadId": "upload_123", "provider": "google-drive", "status": "completed" } A production webhook system should support authentication, retry handling, and duplicate event detection.
This is an example event design, not an official MergeDrive API response.
Where MergeDrive Fits Into This Architecture
The cloud storage management project I'm developing, MergeDrive, addresses several related problem areas:
- Managing multiple Google Drive and OneDrive accounts.
- Smart storage destination selection.
- Account prioritization.
- Priority and scheduled uploads.
- Resumable file uploads.
- Storage availability monitoring.
- Unified cloud storage API and webhooks.
These capabilities illustrate how upload reliability, account management, and storage orchestration can be treated as connected engineering problems.
Project context: MergeDrive.
The implementation examples in this article are general architectural illustrations, not excerpts from MergeDrive's production code or its documented API contracts.
Production Readiness Checklist
Before deploying a resumable file upload API, test scenarios such as:
- Network interruption halfway through an upload.
- Application or worker restart.
- Expired upload sessions.
- Insufficient destination storage.
- Simultaneous uploads to the same account.
- Provider rate limiting.
- Duplicate completion notifications.
- Cancellation during an upload.
- Loss of access to the original file data.
A successful upload under ideal conditions is only the beginning. Reliability comes from handling the unexpected conditions correctly.
Conclusion
A reliable cloud storage file upload API requires more than a simple upload endpoint.
Resumable transfers, persistent session state, provider-specific adapters, priority queues, smart storage selection, and failure recovery can work together to create a more resilient system.
Start with the simplest reliable upload workflow, then introduce scheduling, prioritization, and multi-cloud orchestration as your requirements grow.
How do you handle interrupted large file uploads in your applications? Do you manage upload sessions yourself or rely on provider SDKs?
Disclosure: I am the founder of MergeDrive. This article was drafted using AI. The code examples are illustrative and should be reviewed and tested before production use.
