- File should be uploaded in chunks. Chunks can be uploaded in any order. File can be of any type.
- Chunk size should be configurable.
- There are multiple server instances running on different addresses. Each server knows about every other server. Chunk received on one server should be replicated to other servers so that each server can have the chunk.
- Chunks received on servers should be stitched in correct order to maintain the integrity of the file.
-
Chunk size and a list of servers can be saved in some config file and this file will be read on application startup.
-
An http endpoint will be there to accept a chunk with additional information like offset, agent, total no of chunks that needs to be received, identifier corresponding to this particular file upload.
-
Once a server instance receives a chunk, it will distribute this chunk to other servers only if the agent is client. On receiving this chunk, server will
- Write this chunk to the file with that identifier at the required offset.
- Evaluate if all the chunks have been received. If yes it will return an appropriateg response.
- ./build-1.sh
- ./build-2.sh
- cd client
- go run main.go
curl --location --request POST '127.0.0.1:3001/file'
--form 'file=@/home/use/filename'
a dummy ui to upload file can be accessed at : http://127.0.0.1:3001/index