Unable to load IFileVersion.Size property for items 2GB and greater
See original GitHub issueCategory
- Bug
Describe the bug
For context, the IFile.Length is of type long and IFileVersion.Size if of type int. Both of them are supposed to return the size of the file (or its version) from Sharepoint. Any FileVersion that is larger than an int can hold won’t load the .Size property and trying to load it will throw an exception.
Steps to reproduce
var listItem = await list.Items.GetByIdAsync(1, li => li.All, li => li.Versions.QueryProperties(v => v.All, v => v.FileVersion.QueryProperties(fv => fv.Size)), li => li.File);
//Can't be the current version, as that is just the IFile to handle content, not IFileVersion.
var version = listItem.Versions.AsRequested().FirstOrDefault(v => !v.IsCurrentVersion);
if (version != null) { var size = version.FileVersion.Size; Console.WriteLine($"Size in bytes is {size}"); }
- See code in case it’s just me.
- Load a ListItem and its versions, as well as the fileVersion.Size property.
- Try on a fileVersion smaller than 2GB, it works and prints the size
- Try again on a fileVersion that is larger than 2GB, it throws an exception.
{HttpResponseCode: 400 Code: System.InvalidOperationException Message: Operation is not valid due to the current state of the object. ClientRequestId: } PnP.Core.BaseError {PnP.Core.SharePointRestError}
Expected behavior
Should be able to load the Size property of file versions that are larger than 2GB.
Environment details (development & target environment)
- SDK version: [1.4.0 ]
- OS: [Windows 10]
- SDK used in: [ Console App]
- Framework: [ .NET Core v3.x ]
- Tooling: [Visual Studio 2019]
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Grabbed the latest nightly and looks like the issue is taken care of.
Thanks again for everything you are doing. Really appreciate it!
Thanks for getting to this so quick!
I pulled in the latest today, 1.4.16-nightly. I can see that the type of IFileVersion.Size is a now a long (confirmed in my testing).
However, it still fails to load the property if the size of the versions content is greater than 2147483647 bytes.
This line:
var listItemCheck = await list.PnpList.Items.GetByIdAsync(1, li => li.All, li => li.Versions.QueryProperties(v => v.All, v => v.FileVersion.QueryProperties(fv => fv.Id, fv => fv.Size)), li => li.File.QueryProperties(f => f.Length));
throws the exception:PnP.Core.Services.BatchClient.ProcessSharePointRestBatchResponseContent(PnP.Core.Services.Batch, string) PnP.Core.Services.BatchClient.ProcessSharePointRestBatchResponse(PnP.Core.Services.BatchClient.SPORestBatch, string) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs PnP.Core.Services.BatchClient.ExecuteSharePointRestBatchAsync(PnP.Core.Services.Batch) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs PnP.Core.Services.BatchClient.ExecuteBatch(PnP.Core.Services.Batch) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
If I only request the files length for any size file, it will return the file.Length property no problem.
Again, thanks for looking at it. If you need more information I can try and get it for you.