3

我有个问题。

我有一个 WCF 正在运行。这个想法是该服务会将文件(200MB)上传到 DropBox 帐户。

我试过 SharpBox 和 DropNet。在我尝试上传文件之前,一切都像魅力一样。这意味着登录到保管箱并创建一个文件夹有效,但上传不起作用......

这是我到目前为止所尝试的:

代码sharpBox方式1:

ICloudFileSystemEntry file = _storage.CreateFile(_folderEntry, Path.GetFileName(fileToUpload));

using (FileStream fileStream = new FileStream(fileToUpload, FileMode.Open, FileAccess.Read))
    {

Int32 length = 1024;
    int bytesRead = 0;
    Byte[] buffer = new Byte[length];

    using (Stream data = file.GetContentStream(FileAccess.Write))
    {

        using (BinaryWriter writer = new BinaryWriter(data))
        {

            bytesRead = fileStream.Read(buffer, 0, length);
            // write the required bytes
            while (bytesRead > 0)
            {
                bytesRead = fileStream.Read(buffer, 0, length);
                writer.Write(buffer, 0, bytesRead);
            }

        }
    }
}

代码sharpBox方式2:

_storage.UploadFile(fileToUpload, _folderEntry);

代码 DropNet 方式 3:

byte[] content = _client.GetFileContentFromFS(new FileInfo(fileToUpload)); 
_client.UploadFile(_dropBoxFolder, Path.GetFileName(fileToUpload), content);

在网络配置中:

<httpRuntime maxRequestLength="2097151" executionTimeout="3600" />

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483648"/>
  </requestFiltering>
</security>

/Göran

4

1 回答 1

0

您是否在 Web 配置中设置了最大文件长度?

<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
于 2011-03-22T13:05:32.337 回答