Closed stefan-adna closed 7 months ago
When using the AssetCanisterApiClient Class to upload files there is a problem when chunking the file.
int bytesRead = await contentStream.ReadAsync(buffer.AsMemory()); ... byte[] chunkBytes = bytesRead < buffer.Length ? buffer[0..(bytesRead - 1)] : buffer;
The upper bound of the array selector is exclusive, meaning reading 5 bytes should be buffer[0..5] which reads position 0-4 therefore the correct code should be buffer[0..(bytesRead - 1)] (without the -1).
buffer[0..5]
buffer[0..(bytesRead - 1)]
Nice catch, ill fix
Fixed in 6.1.0
Very nice. Looks good. Thanks a lot 👍
When using the AssetCanisterApiClient Class to upload files there is a problem when chunking the file.
The upper bound of the array selector is exclusive, meaning reading 5 bytes should be
buffer[0..5]
which reads position 0-4 therefore the correct code should bebuffer[0..(bytesRead - 1)]
(without the -1).