How to improve speed when uploading large files using OneDrive SDK RRS feed

  • Question

  • User-1404740798 posted

    It is a REST API implemented in .net core.

    When uploading large file attachments using OneDrive SDK, the speed is too slow.

    It takes about 45 minutes to 1 hour based on 1GB file.

    Is there any way to improve the problem?

    public async Task<JObject> UploadLargeFiles(string upn, IFormFile files)
            var jObject = new JObject();
            int fileSize = Convert.ToInt32(files.Length);
            var fileStream = files.OpenReadStream();
            GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient();
            var uploadProps = new DriveItemUploadableProperties
                ODataType = null,
                AdditionalData = new Dictionary<string, object>
                    { "@microsoft.graph.conflictBehavior", "rename" }
            var item = this.SelectUploadFolderID(upn).Result;
            var uploadSession = await client.Users[upn].Drive.Items[item].ItemWithPath(files.FileName).CreateUploadSession(uploadProps).Request().PostAsync();
            int maxChunkSize = 320 * 1024;
            var uploadTask = new LargeFileUploadTask<DriveItem>(uploadSession, fileStream, maxChunkSize);
            var response = await uploadTask.UploadAsync();
            if (response.UploadSucceeded)
                jObject = JObject.FromObject(new { result = "success"});
                return jObject;
                return null;
    Tuesday, November 3, 2020 6:35 AM

All replies

  • User-474980206 posted

    You need a faster internet provider. You are getting about 6mbs upload, which is typical for a cable provider. If you switch to fiber, you can get up to gigabit speed. Unlike cable, with fiber typically its upload speed is faster than its download.

    Tuesday, November 3, 2020 3:56 PM
  • User-1404740798 posted

    Is it an internet problem, not a code problem?

    Are there any speed issues with that code?

    Wednesday, November 4, 2020 8:02 AM