I recently tried Dropnet API to connect dropbox app in my C# project. Everything works fine, but I want to upload large files through chunkupload request.
public void FileUpload()
{
string file = @"E:\threading.pdf";
int chunkSize = 1 * 1024 * 1024;
var buffer = new byte[chunkSize];
int bytesRead;
int chunkCount = 0;
ChunkedUpload chunkupload = null;
using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
{
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0)
{
chunkCount++;
if (chunkCount == 1)
{
chunkupload = client.StartChunkedUpload(buffer);
}
else
{
chunkupload = client.AppendChunkedUpload(chunkupload, buffer);
}
}
}
var metadata = client.CommitChunkedUpload(chunkupload, "/threading.pdf", true);
}
The file size is 1.6 MB. When i Checked, first chunk contains 1 MB and second one contains 0.6MB but only 13 bytes data gets uploaded in each chunk. Could anyone point out problem here.