I assume the USB storage is connected to the NETMF device and the WebServer is somewhere in the internet.
I can not help you with the HTTP stuff, but I can assist you with uploading the file.
Normally you have some kind of stream where you write your data to (uploadStream).
And you have a fileStream to the file on USB device.
Then you create a ‘small’ buffer (lets say about 10k) to which you read from file and the write to uploadStream.
// get the uploadStream from HTTP request, FTP, ...
var uploadStream = ...
//open file
using (var fileSTream = new FileStream("path to file"))
{
var buffer = new byte[10 * 1024]; // you can adjust the buffer size to get optimal performance
// read 1st chunk
int cnt = fileStream.Read(buffer, 0, buffer.Length);
while(cnt > 0)
{
// write to upload stream
uploadStream.Write(buffer, 0, cnt);
// read next chunk
cnt = fileStream.Read(buffer, 0, buffer.Length);
}
}
// done, close/finalize uploadStream if necessary
I hope this helps.
(code is actually not checked for syntax errors, just typed it directly in here)
actually i am looking for a solution to uploading very large file over HTTP to our web server
buffering is good for reading large file but how can we send this splitted packets to our server ?