Skip to content

Commit

Permalink
Open read, functional
Browse files Browse the repository at this point in the history
  • Loading branch information
titouancreach committed May 11, 2023
1 parent 16125c4 commit 0415ef2
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,27 @@ private static Result AssertGuardsF(this IAzureBlobStorageProvider storage)
public static async Task<Result<(Uri, BlobContentInfo)>> FUploadAsync(this IAzureBlobStorageProvider storage, string b64) => await storage
.AssertGuardsF()
.Bind(async () => await storage.FUploadAsync(new MemoryStream(Convert.FromBase64String(b64))));


public static Result<(Stream, BlobProperties)> FOpenRead(this IAzureBlobStorageProvider storage)
{
return Result.Try(() =>
{
var (stream, blob) = storage.OpenRead();

if (blob.Value is null)
{
return Result.Failure<(Stream, BlobProperties)>("OpenRead failed");
}

if (stream is null)
{
return Result.Failure<(Stream, BlobProperties)>("OpenRead failed");
}

return Result.Success((stream, blob.Value));

}).Bind(x => x);
}
}

0 comments on commit 0415ef2

Please sign in to comment.