0

I'm using dropnet to upload files to the dropbox. Until then everything is working well, but only for small files on it. The following code I'm using to send:

private void btnEnviar_Click(object sender, EventArgs e)
{
    var _client = new DropNetClient("xxxxxxxxxxxxx", "xxxxxxxxxxxxxx", "xxxxxxxxxxxxx", "xxxxxxxxxxxxxxxx");
    _client.UseSandbox = true;

    string arq = "";
    string path = "";
    foreach (DataGridViewRow dr in dgvArquivos.Rows)
    {
        if (dr.Cells[0].Value != null)
        {
            arq = dr.Cells[3].Value.ToString();
            path = "//server/documentos/Scanner_/exames";
            try
            {

                var filebytes = new FileInfo(@path+"/"+arq);
                byte[] content = _client.GetFileContentFromFS(filebytes);
                var result=_client.UploadFile("/exames",arq,content);
                this.lblMsg.Text = result.ToString();
                dr.Cells[4].Value = "17/12/2014";
            }
            catch (Exception ex)
            {

                this.lblMsg.Text= ex.Message.ToString();
            }
        }

    }
}

How do I send files larger on average than 50mb?

Jcl
  • 27,696
  • 5
  • 61
  • 92
  • When it doesn't work, what is the error? – Jcl Dec 18 '14 at 16:05
  • Hi, Check this out: https://www.dropbox.com/developers/core/docs. It says /files_put has a maximum file size limit of 150 MB and does not support uploads with chunked encoding. To upload larger files, use /chunked_upload instead. So I am not sure why 50MB is erroring based on this information but you should use chunked_upload option to see if it works. – Hozikimaru Dec 18 '14 at 17:45

1 Answers1

0

Depending on the actual error you're getting the answer might change. ie, if its out of memory or a HTTP error from the API.

DropNet does have support for chunked uploading of files which you might want to have a look at. Documentation for it is a little lacking at the moment but looking at the source should tell you how to use it. https://github.com/DropNet/DropNet/blob/master/DropNet/Client/Files.Sync.cs#L224

Making a call to StartChunkedUpload to start the upload, call AppendChunkedUpload to append more bytes to the upload then call CommitChunkedUpload to complete the upload. Use this with a streaming read of the file if possible to reduce the memory usage.

dkarzon
  • 7,868
  • 9
  • 48
  • 61