LiteDB db.FileStorage.Upload stream method never uploads anything

Solution for LiteDB db.FileStorage.Upload stream method never uploads anything
is Given Below:

Saving files to LiteDb with the following:

private async Task SaveFile(IFormFile file, string someFileName)
{
    using var stream = new MemoryStream();
    await file.CopyToAsync(stream);
    db.FileStorage.Upload(SOMEPATHID, someFileName, stream);

    // here just so i can verify the collection has no file data.
    var entireCollection = db.FileStorage.Find(p => true); 
}

The stream is a valid IFormFile received on a controller and i can verify the stream is valid and has content.

This throws no errors and executes normally with the exception that it ends up with a stored file but with no chunks stored.
All info is available except the file data.

After bashing my head for a while i realized the stream was actually failing to read due to the initial position of the stream reader.

Adding a stream.Position = 0; before attempting to upload solves the issue.

private async Task SaveFile(IFormFile file, string someFileName)
{
    using var stream = new MemoryStream();
    await file.CopyToAsync(stream);
    stream.Position = 0; //reset stream pointer.
    db.FileStorage.Upload(SOMEPATHID, someFileName, stream);

    //collection now has data !
    var entireCollection = db.FileStorage.Find(p => true);
}

or even simpler and never having the whole file in memory you just use file.OpenReadStream() directly on the db.fileStorage.Upload like so:

private async Task SaveFile(IFormFile file, string someFileName)
{
    db.FileStorage.Upload(SOMEPATHID, someFileName, file.OpenReadStream());

    //collection still has data !
    var entireCollection = db.FileStorage.Find(p => true);
}