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?
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.