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

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.