Backend Development 10 min read

Implementing High‑Performance Large File HTTP Upload with Resume Support Using C Server and HTML5/JavaScript

This article explains how to build a high‑performance large‑file HTTP upload system with breakpoint resume, detailing server‑side C implementation, immediate disk writes, client‑side hash generation, cookie‑based IDs, and JavaScript code for chunked uploading, progress tracking, and error handling.

Architecture Digest
Architecture Digest
Architecture Digest
Implementing High‑Performance Large File HTTP Upload with Resume Support Using C Server and HTML5/JavaScript

To meet product requirements for high‑performance large file HTTP uploads with breakpoint resume, the author outlines three key points: use a C server (instead of interpreted languages), write directly to disk to avoid memory buffering, and support HTML5/IFRAME with progress tracking.

The client (usually a browser) generates a unique hash for each file, combining a browser‑assigned ID (stored in a cookie), file modification time, name, and size, then computes an MD5 hash (optionally using the file content). This hash is used to query the server for already uploaded bytes.

Key client‑side functions include:

function setCookie(cname,cvalue,exdays){...}
function getCookie(cname){...}
function getFileId(file){...}

After obtaining the file ID, the client sends a GET request to resume_info_url with fileid and a timestamp to retrieve resume information. The response indicates the uploaded size, allowing the client to continue uploading from that offset.

The upload process uses the HTML5 File.slice method to create blobs for each chunk and sends them via XMLHttpRequest . The upload_file function manages chunk boundaries, progress calculation, bitrate display, and UI updates.

function upload_file(fileObj,start_offset,fileid){...}

Event listeners handle progress ( uploadProgress ), completion ( uploadComplete ), errors ( uploadFailed ), and cancellations ( uploadCanceled ), updating the UI accordingly.

A simple HTML interface demonstrates real‑time progress, uploaded size, and bitrate, and the author provides a GitHub repository ( https://github.com/wenshui2008/UploadServer ) for testing the server implementation.

JavaScriptFile UploadHTML5Large FilesC serverHTTP resume
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.