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;
}
else
{
return null;
}
}
I have followed the examples/guidance's provided at blogpost and it worked for me. I know uploading bigger files may take a while, give a fact that it depends on the internet speed, so i will exclude Graph API out of the picture here. Apart from that i dont see any options to speedup. Also you can consider filing uservoice.