question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load IFileVersion.Size property for items 2GB and greater

See original GitHub issue

Category

  • 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}"); }

  1. See code in case it’s just me.
  2. Load a ListItem and its versions, as well as the fileVersion.Size property.
  3. Try on a fileVersion smaller than 2GB, it works and prints the size
  4. 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
WillickDNcommented, Oct 19, 2021

Grabbed the latest nightly and looks like the issue is taken care of.

Thanks again for everything you are doing. Really appreciate it!

1reaction
WillickDNcommented, Oct 16, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to upload bigger than 2GB file to Share Point Online ...
File size limit for a file in SPO library is greater than 2 GB (10 or 100 GB). Yet, with ordinary file.add even...
Read more >
Spring upload file size limit error - java
Dependes on Spring boot Version , example 1.X, on your application.properties, set the file size limit:
Read more >
PowerShell PnP Unable to get file versions in big files
It works absolutely fine, BUT when the file is big (let say > 1GB), ALWAYS get this error trying to get its versions....
Read more >
uninstall NA - ITOM Practitioner Portal - Micro Focus
Failed to upload zip file of size greater than 2GB to NA Software Image Repository · Cause · Solution.
Read more >
Why don't the sizes of my folders add up to ...
You can check by opening the properties dialog of a partition in Windows' file explorer.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found