There is no built-in chunking. You will need to implement it yourself. It should be pretty straightforward.
Some interface like the following should do the trick:
Guid GetFile(string filename);
Guid GetFile(string filename, out int chunkCount);
byte[] GetFileChunk(Guid id, int chunkIndex);
When GetFile()
is called the server can 'cache' the file in a Dictionary<>
against a Guid
that acts as the key. Then this Guid
can be returned back to the client so that it can make further requests to download the actual chunks of the file.
GetFileChunk()
should return null if the chunkIndex exceeds the number of chunks for that Guid / file.
The size of the chunks if up to you. You have a choice between responsiveness and performance. The larger the chunks the better the performance will be. But if you are updating a progress bar or something on a GUI then of course the 'responsiveness' will be adversely affected. Try experimenting with what works best.
An alternative interface may be something like:
Guid GetFile(string filename, out ulong numOfBytes);
byte[] GetFileData(Guid id, ulong index, ulong count);
This would mean the client could decide the size of the chunks it wishes to download. And then you could implement some sort of scaling strategy.