Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit fe1c89d

Browse files
committed
Added support for retrieving the next batch of files in a large folder
1 parent 20b9e09 commit fe1c89d

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

Api/API.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
<AssemblyName>KoenZomers.OneDrive.Api</AssemblyName>
66
<SignAssembly>true</SignAssembly>
77
<AssemblyOriginatorKeyFile>KoenZomers.OneDrive.Api.snk</AssemblyOriginatorKeyFile>
8-
<Version>2.3.1.1</Version>
8+
<Version>2.3.2.0</Version>
99
<Authors>Koen Zomers</Authors>
1010
<Company>Koen Zomers</Company>
1111
<Description>API in .NET Standard 2.0, .NET Framework 4.5.2, .NET Framework 4.7.2 and .NET Core 2.0 to communicate with OneDrive Personal and OneDrive for Business</Description>
1212
<PackageProjectUrl>https://github.com/KoenZomers/OneDriveAPI</PackageProjectUrl>
1313
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14-
<PackageReleaseNotes>- Fixed bug in using copy [Issue 24](https://github.com/KoenZomers/OneDriveAPI/issues/24)</PackageReleaseNotes>
14+
<PackageReleaseNotes>- Added ```public virtual async Task&lt;OneDriveItemCollection&gt; GetNextChildrenByPath(string skipTokenUrl)``` which allows file requests from using i.e. ```public virtual async Task&lt;OneDriveItemCollection&gt; GetChildrenByPath(string path)``` on a large folder containing more than 100 files to retrieve the next batch of files. If your intend is to get all the results, use ```public virtual async Task&lt;OneDriveItem[]&gt; GetAllChildrenByPath(string path)``` instead. [Issue 28](https://github.com/KoenZomers/OneDriveAPI/issues/28)</PackageReleaseNotes>
1515
<PackageLicenseUrl>https://github.com/KoenZomers/OneDriveAPI/blob/master/LICENSE.md</PackageLicenseUrl>
1616
<Copyright>Koen Zomers</Copyright>
1717
<RootNamespace>KoenZomers.OneDrive.Api</RootNamespace>
18-
<AssemblyVersion>2.3.1.1</AssemblyVersion>
19-
<FileVersion>2.3.1.1</FileVersion>
18+
<AssemblyVersion>2.3.2.0</AssemblyVersion>
19+
<FileVersion>2.3.2.0</FileVersion>
2020
</PropertyGroup>
2121

2222
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">

Api/KoenZomers.OneDrive.Api.xml

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Api/OneDriveApi.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public virtual async Task<OneDriveItem[]> GetAllDriveRootChildren()
354354
}
355355

356356
/// <summary>
357-
/// Retrieves the first batch of children under the provided OneDrive path
357+
/// Retrieves the first batch of children under the provided OneDrive path. Use GetNextChildrenByPath and provide the NextLink from the results to fetch the next batch.
358358
/// </summary>
359359
/// <param name="path">Path within OneDrive to retrieve the child items of</param>
360360
/// <returns>OneDriveItemCollection containing the first batch of items in the requested folder</returns>
@@ -363,6 +363,16 @@ public virtual async Task<OneDriveItemCollection> GetChildrenByPath(string path)
363363
return await GetData<OneDriveItemCollection>(string.Concat("drive/root:/", path, ":/children"));
364364
}
365365

366+
/// <summary>
367+
/// Retrieves a next batch of children using the provided full SkipToken path
368+
/// </summary>
369+
/// <param name="skipTokenUrl">Full URL from a NextLink in the response of a GetChildrenByPath request</param>
370+
/// <returns>OneDriveItemCollection containing the next batch of items in the requested folder</returns>
371+
public virtual async Task<OneDriveItemCollection> GetNextChildrenByPath(string skipTokenUrl)
372+
{
373+
return await GetData<OneDriveItemCollection>(skipTokenUrl);
374+
}
375+
366376
/// <summary>
367377
/// Retrieves all children under the provided OneDrive path
368378
/// </summary>

Demo/MainForm.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,14 @@ private string SelectLocalFile()
266266
/// </summary>
267267
private async void GetByPathButton_Click(object sender, EventArgs e)
268268
{
269-
var data = await OneDriveApi.GetChildrenByPath("Demo");
269+
var data = await OneDriveApi.GetChildrenByPath("Test");
270270
JsonResultTextBox.Text = data != null ? data.OriginalJson : "Not available";
271+
272+
if (data.NextLink != null)
273+
{
274+
var nextData = await OneDriveApi.GetNextChildrenByPath(data.NextLink);
275+
JsonResultTextBox.Text += nextData != null ? nextData.OriginalJson : "";
276+
}
271277
}
272278

273279
/// <summary>

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ https://www.nuget.org/packages/KoenZomers.OneDrive.Api
6969

7070
## Version History
7171

72+
2.3.2.0 - February 2, 2021
73+
74+
- Added ```public virtual async Task<OneDriveItemCollection> GetNextChildrenByPath(string skipTokenUrl)``` which allows file requests from using i.e. ```public virtual async Task<OneDriveItemCollection> GetChildrenByPath(string path)``` on a large folder containing more than 100 files to retrieve the next batch of files. If your intend is to get all the results, use ```public virtual async Task<OneDriveItem[]> GetAllChildrenByPath(string path)``` instead. [Issue 28](https://github.com/KoenZomers/OneDriveAPI/issues/28)
75+
7276
2.3.1.1 - November 16, 2020
7377

7478
- Fixed bug in using copy [Issue 24](https://github.com/KoenZomers/OneDriveAPI/issues/24). Thanks to [Eirielson Rodrigues](https://github.com/eirielson) for reporting this!

0 commit comments

Comments
 (0)