Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/alexchx/pnpcore into pr1387
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Feb 12, 2024
2 parents 40d983d + 7193078 commit 43acd38
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ private static async Task<File> ChunkedFileUpload(File newFile, Stream content,

var buffer = new byte[chunkSizeBytes];
int bytesRead;
while ((bytesRead = content.Read(buffer, 0, buffer.Length)) > 0)
while (true)
{
bytesRead = content.Read(buffer, 0, buffer.Length);

// A chunk can be returned smaller than the bytes requested. See https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.read?view=net-5.0&viewFallbackFrom=net-3.1#System_IO_Stream_Read_System_Byte___System_Int32_System_Int32_
// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available,
// or zero (0) if the end of the stream has been reached.
Expand Down Expand Up @@ -135,6 +137,8 @@ private static async Task<File> ChunkedFileUpload(File newFile, Stream content,
BinaryBody = chunk
};
await newFile.RequestAsync(api, HttpMethod.Post).ConfigureAwait(false);

break;
}
else
{
Expand Down

0 comments on commit 43acd38

Please sign in to comment.