1

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.

Rajeev Ranjan
  • 4,152
  • 3
  • 28
  • 41
  • It seems you'll need another buffer with size of bytesRead as dropnet api doesn't take the length parameters, you'll end up with garbage at the end of the buffer for some of the chunks. – smoothdeveloper May 01 '15 at 23:29

2 Answers2

1

Update RestSharp to 104.4.0 to resolve this issue.

Austin Thompson
  • 2,251
  • 1
  • 17
  • 23
0

There's a problem with RestSharper that is used by Dropnet. Each uploaded chunk uploads exactly 13 bytes 'System.Byte[]'

The problem is that array of bytes is converted to string using method 'AddParameter'.

I didn't dig too much. I'm trying to use UploadFile method.