#StackBounty: #c# #.net #sharepoint #microsoft-graph-api SharePoint file size is different than source file after uploading

Bounty: 50

We are developing a WinForms (desktop) application in .Net framework 4.5.2 with C# language.

Using Microsoft.Graph library 1.21.0 and Micorosft.Graph.Core 1.19.0 version to copy files from windows local machine to SharePoint/OneDrive cloud storage.

I tried with Microsoft.Graph library 3.18.0 and Micorosft.Graph.Core 1.22.0 and .Net 4.6.2 framework but same issue.

  1. We are copy files less than 4 MB using following method

uploadedItem = await

  1. Files larger than 4 MB are being copied using ChunkUpload
var session = await MainDrive.Root.ItemWithPath(targetFilePath).CreateUploadSession().Request().PostAsync(cancellationToken);
var provider = new ChunkedUploadProvider(session, graphClient, stream, OneDriveChunkSize);

var chunkRequests = provider.GetUploadChunkRequests();  

var trackedExceptions = new List<Exception>();

foreach (UploadChunkRequest request in chunkRequests)
   await CheckforBandwidthThrotelling(fileInfo.Name, fp, cancellationToken);
   UploadChunkResult result = await provider.GetChunkRequestResponseAsync(request, trackedExceptions);
   if (result.UploadSucceeded)
    uploadedItem = result.ItemResponse;

Issue: We are getting the file size larger than source after copying files to SharePoint. It works well in case of OneDrive personal using same api’s and method.
I found that it’s due to Metadata get added to file. We are not maintaining any multiple version of files on SharePoint.
This issue is mostly with office files (docs, xlsx and ppt) but not with txt files of any size.

The application differentiate the files mismatch on source and destination based upon timestamp and file size. As file found different size in next run, it copies the file again.

The same issue is reported on github

Some more description about issue

I am looking for a workaround to compare file size between source and destination to decide whether file need to copy again.

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.