0

I am trying to upload file to an sharepoint online server using webclient. Up to about 7MB i have no problem. After 7 MB starting to get Timeout error. Size of file can vary depending on server status or network status. This occurs when loading time exceeds 2 minutes. Does anyone knows way to set timeout value for the sharepoint online in runtime or permanent configuration. I am using following method to upload file.

    public void AddFile(string fullFileUrl, Stream fileData)
    {

        WebClient _webClient = new WebClient();
        var writeStream = _webClient.OpenWrite(fullFileUrl, "Put");
        var buffer = new byte[BufferSize];
        while (true)
        {
            var bytesRead = fileData.Read(buffer, 0, BufferSize);
            if (bytesRead <= 0)
                break;
            writeStream.Write(buffer, 0, bytesRead);
        }

        writeStream.Flush();
        writeStream.Close();
    }

Thanks

haltunbay

haltunbay
  • 615
  • 6
  • 15
  • same issue at http://stackoverflow.com/questions/601861/set-timeout-for-webclient-downloadfile helped me – haltunbay Jun 25 '12 at 08:29

1 Answers1

1

In the HttpRuntime element, you can add the attribute 'executiontimeout' to increase this

However if possible you could run the upload asynchronously or through an HttpHandler to avoid the timeout issue altogether

Joe
  • 39
  • 3