This project demonstrates a file upload system with support for parallel, chunked uploads. It is designed to efficiently handle large files by splitting them into smaller chunks and uploading them, improving reliability and performance.
- The client requests a new upload session from
/upload-chunk-parallel/start. - The server generates a unique
uploadIdand creates a directory for incoming chunks.
- The frontend JavaScript splits the selected file into chunks (default: 200KB per chunk).
- Each chunk is sent to
/upload-chunk-parallel/processwith:uploadIdchunkIndex(order of the chunk)fileLength(optional, the total length of the file)chunkLength- The chunk data itself
- Multiple chunks can be uploaded in parallel for speed (the current implementation uploads sequentially, but can be easily parallelized by sending multiple requests at once).
- The server saves each chunk in a temporary directory, named by
chunkIndex.
- After all chunks are uploaded, the client calls
/upload-chunk-parallel/completewith theuploadIdand final file name. - The server merges all chunks in order, assembles the final file, and cleans up temporary chunk files.
- The client requests a new upload session from
/upload-chunk-override/start. - The server generates a unique
uploadIdand creates a directory for incoming chunks.
- The frontend JavaScript splits the selected file into chunks (default: 200KB per chunk).
- Each chunk is sent to
/upload-chunk-override/processwith:uploadIdchunkIndex(order of the chunk)fileLengthfileNamechunkLength- The chunk data itself
- Multiple chunks can be uploaded
- Once server receives chunks are uploaded, server appends them to the final file by order.
- Start server
- Go to
/fefolder runindex.html - Select large file upload
POST /upload-chunk-parallel/start– Start a new upload, returnsuploadId.POST /upload-chunk-parallel/process– Upload a chunk (multipart/form-data).POST /upload-chunk-parallel/complete– Merge chunks and complete upload.
POST /upload-chunk-override/start– Start a new upload, returnsuploadId.POST /upload-chunk-override/process– Upload a chunk (multipart/form-data).
- Chunk size can be adjusted in
fe/common.js(chunkSizevariable). - The backend ensures security by validating chunk paths and cleaning up after merging.
- This approach improves reliability for large files and allows for resumable uploads or retrying failed chunks in the future.
Feel free to extend this README with more details or usage examples as needed.