[英]Upload large file using dropnet
我正在使用dropnet将文件上传到Dropbox。 在此之前,一切工作正常,但仅适用于其中的小文件。 我正在使用以下代码发送:
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();
}
}
}
}
如何发送平均大于50mb的文件?
根据实际错误,答案可能会有所不同。 也就是说,如果内存不足或API发出HTTP错误。
DropNet确实支持分块上传文件,您可能需要看看。 目前尚缺少有关它的文档,但是查看源代码应该告诉您如何使用它。 https://github.com/DropNet/DropNet/blob/master/DropNet/Client/Files.Sync.cs#L224
调用StartChunkedUpload
开始上传,调用AppendChunkedUpload
将更多字节追加到上传中,然后调用CommitChunkedUpload
完成上传。 如果可能,可将此选项与流式读取文件一起使用,以减少内存使用量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.