Add legacy ASP.NET Core 3.1 version of this app

This commit is contained in:
2024-09-11 21:53:17 -07:00
parent 130312301e
commit 3777cb4fac
11 changed files with 330 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.IO;
internal class LargeStreamResult : Stream
{
private long _position = 0;
private const long _length = 8L * 1024L * 1024L * 1024L; // 8 GB
public override bool CanRead => true;
public override bool CanSeek => true;
public override bool CanWrite => false;
public override long Length => _length;
public override long Position { get => _position; set => _position = value; }
public override void Flush() { }
public override int Read(byte[] buffer, int offset, int count)
{
int bytesToRead = (int)Math.Min(count, _length - _position);
if (bytesToRead <= 0)
return 0;
_position += bytesToRead;
return bytesToRead;
}
public override long Seek(long offset, SeekOrigin origin)
{
switch (origin)
{
case SeekOrigin.Begin:
_position = offset;
break;
case SeekOrigin.Current:
_position += offset;
break;
case SeekOrigin.End:
_position = _length + offset;
break;
}
return _position;
}
public override void SetLength(long value) { }
public override void Write(byte[] buffer, int offset, int count) { }
}