简体   繁体   English

使用dropnet上传大文件

[英]Upload large file using dropnet

I'm using dropnet to upload files to the dropbox. 我正在使用dropnet将文件上传到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? 如何发送平均大于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. 也就是说,如果内存不足或API发出HTTP错误。

DropNet does have support for chunked uploading of files which you might want to have a look at. DropNet确实支持分块上传文件,您可能需要看看。 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 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. 调用StartChunkedUpload开始上传,调用AppendChunkedUpload将更多字节追加到上传中,然后调用CommitChunkedUpload完成上传。 Use this with a streaming read of the file if possible to reduce the memory usage. 如果可能,可将此选项与流式读取文件一起使用,以减少内存使用量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM