@@ -91,19 +91,21 @@ public async Task<string> CreateMediaInputAsset(IFormFile file)
91
91
/// <returns>.</returns>
92
92
public async Task < BlobDownloadResult > DownloadMediaInputAsset ( string inputAssetName , string fileName )
93
93
{
94
- IAzureMediaServicesClient client = await this . CreateMediaServicesClientAsync ( ) ;
94
+ var client = this . GetMKIOServicesClientAsync ( ) ;
95
+ var assets = client . Assets . Get ( inputAssetName ) ;
96
+
97
+ BlobServiceClient blobServiceClient = new BlobServiceClient ( this . settings . MediaKindSettings . MediaKindStorageConnectionString ) ;
95
98
96
- AssetContainerSas assetContainerSas = await client . Assets . ListContainerSasAsync (
97
- this . settings . AzureMediaResourceGroup ,
98
- this . settings . AzureMediaAccountName ,
99
- inputAssetName ,
100
- permissions : AssetContainerPermission . Read ,
101
- expiryTime : DateTime . UtcNow . AddHours ( 1 ) . ToUniversalTime ( ) ) ;
99
+ BlobContainerClient containerClient = blobServiceClient . GetBlobContainerClient ( assets . Properties . Container ) ;
100
+ if ( ! await containerClient . ExistsAsync ( ) . ConfigureAwait ( false ) )
101
+ {
102
+ await containerClient . CreateIfNotExistsAsync ( ) . ConfigureAwait ( false ) ;
103
+ }
102
104
103
- string sasUri = assetContainerSas . AssetContainerSasUrls . First ( ) ;
105
+ var filename1 = Regex . Replace ( fileName , "[^a-zA-Z0-9.]" , string . Empty ) ;
106
+ filename1 = string . IsNullOrEmpty ( filename1 ) ? "file.txt" : filename1 ;
104
107
105
- var blobServiceClient = new BlobContainerClient ( new Uri ( sasUri ) ) ;
106
- var blobClient = blobServiceClient . GetBlockBlobClient ( fileName ) ;
108
+ BlobClient blobClient = containerClient . GetBlobClient ( filename1 ) ;
107
109
var fileContent = await blobClient . DownloadContentAsync ( ) ;
108
110
109
111
return fileContent ;
0 commit comments