Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<VersionPrefix>1.22.0</VersionPrefix>
<VersionPrefix>1.23.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageReleaseNotes>- BaseRequestBuilder is now an IBaseRequestBuilder.
- Requests that return an OData primitive now work as expected.
<PackageReleaseNotes>
- Fix for #120: Exception thrown when slice size is not specified for LargeFileUploadTask
</PackageReleaseNotes>
</PropertyGroup>
<!--We manually configure LanguageTargets for Xamarin due to .Net SDK TFMs limitation https://github.com/dotnet/sdk/issues/491 -->
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Graph.Core/Tasks/LargeFileUploadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Graph
/// </summary>
public class LargeFileUploadTask<T>
{
private const int DefaultMaxSliceSize = 4 * 1024 * 1024;
private const int DefaultMaxSliceSize = 5 * 1024 * 1024;
private const int RequiredSliceSizeIncrement = 320 * 1024;
private IUploadSession Session { get; set; }
private readonly IBaseClient _client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,37 @@ public void ThrowsArgumentExceptionOnInvalidSliceSize()
}
}

[Fact]
public void ShouldNotThrowArgumentExceptionOnConstructorWithoutSliceSize()
{
// Try to upload 1Mb stream without specifying the slice size(should default to 5Mb)
byte[] mockData = new byte[1000000];
using (Stream stream = new MemoryStream(mockData))
{
// Arrange
IUploadSession uploadSession = new Graph.Core.Models.UploadSession
{
NextExpectedRanges = new List<string>() { "0-" },
UploadUrl = "http://localhost",
ExpirationDateTime = DateTimeOffset.Parse("2019-11-07T06:39:31.499Z")
};

// Act with constructor without chunk length
var fileUploadTask = new LargeFileUploadTask<DriveItem>(uploadSession, stream);
var uploadSlices = fileUploadTask.GetUploadSliceRequests();

// Assert
//We have only 1 slices
Assert.Single(uploadSlices);

var onlyUploadSlice = uploadSlices.First();
Assert.Equal(stream.Length, onlyUploadSlice.TotalSessionLength);
Assert.Equal(0, onlyUploadSlice.RangeBegin);
Assert.Equal(stream.Length - 1, onlyUploadSlice.RangeEnd);
Assert.Equal(stream.Length , onlyUploadSlice.RangeLength); //verify the last slice is the right size
}
}

[Fact]
public void BreaksDownStreamIntoRangesCorrectly()
{
Expand Down