11using System ;
2+ using System . Collections . Generic ;
3+ using System . Runtime . CompilerServices ;
4+ using System . Threading ;
25using System . Threading . Tasks ;
36using ManagedCode . Communication ;
47using ManagedCode . Storage . Core ;
58using ManagedCode . Storage . Core . Models ;
69using Microsoft . AspNetCore . Components . Forms ;
10+ using Microsoft . AspNetCore . Http ;
711using Microsoft . AspNetCore . Mvc ;
812
913namespace ManagedCode . Storage . AspNetExtensions ;
@@ -28,4 +32,46 @@ protected async Task<Result<BlobMetadata>>UploadToStorageAsync(IBrowserFile form
2832 {
2933 return await _storage . UploadToStorageAsync ( formFile , options ) ;
3034 }
35+
36+ protected async Task < Result < FileResult > > DownloadAsFileResult ( string blobName , CancellationToken cancellationToken = default )
37+ {
38+ return await _storage . DownloadAsFileResult ( blobName , cancellationToken ) ;
39+ }
40+ protected async Task < Result < FileResult > > DownloadAsFileResult ( BlobMetadata blobMetadata , CancellationToken cancellationToken = default )
41+ {
42+ return await _storage . DownloadAsFileResult ( blobMetadata , cancellationToken ) ;
43+ }
44+
45+ protected async Task < Result < BlobMetadata > > UploadToStorageAsync ( IFormFile formFile ,
46+ UploadOptions ? options = null ,
47+ CancellationToken cancellationToken = default )
48+ {
49+ return await _storage . UploadToStorageAsync ( formFile , options , cancellationToken ) ;
50+ }
51+
52+ protected async Task < Result < BlobMetadata > > UploadToStorageAsync ( IFormFile formFile ,
53+ Action < UploadOptions > options ,
54+ CancellationToken cancellationToken = default )
55+ {
56+ return await _storage . UploadToStorageAsync ( formFile , options , cancellationToken ) ;
57+ }
58+ protected async IAsyncEnumerable < Result < BlobMetadata > > UploadToStorageAsync ( IFormFileCollection formFiles ,
59+ UploadOptions ? options = null ,
60+ [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
61+ {
62+ foreach ( var formFile in formFiles )
63+ {
64+ yield return await _storage . UploadToStorageAsync ( formFile , options , cancellationToken ) ;
65+ }
66+ }
67+ protected async IAsyncEnumerable < Result < BlobMetadata > > UploadToStorageAsync ( IFormFileCollection formFiles ,
68+ Action < UploadOptions > options ,
69+ [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
70+ {
71+ foreach ( var formFile in formFiles )
72+ {
73+ yield return await _storage . UploadToStorageAsync ( formFile , options , cancellationToken ) ;
74+ }
75+ }
76+
3177}
0 commit comments