diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/AzureStorageAssetPublisher.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/AzureStorageAssetPublisher.cs index 264f50a48de..5fefec303a2 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/AzureStorageAssetPublisher.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/AzureStorageAssetPublisher.cs @@ -4,7 +4,9 @@ using System; using System.Threading; using Azure.Storage.Blobs; +using Azure.Storage.Blobs.Models; using Microsoft.Build.Utilities; +using Microsoft.DotNet.Build.CloudTestTasks; #if !NET472_OR_GREATER using Microsoft.DotNet.Maestro.Client.Models; #endif @@ -52,7 +54,11 @@ public async Task PublishAssetAsync(string file, string blobPath, PushOptions op try { - await blobClient.UploadAsync(file); + BlobUploadOptions blobUploadOptions = new() + { + HttpHeaders = AzureStorageUtils.GetBlobHeadersByExtension(file) + }; + await blobClient.UploadAsync(file, blobUploadOptions); } catch (Exception e) { diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs index a2c63e40b3c..4bae23fba6e 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs @@ -22,13 +22,13 @@ namespace Microsoft.DotNet.Build.CloudTestTasks { public class AzureStorageUtils { - private readonly Dictionary MimeMappings = new Dictionary() + private static readonly Dictionary MimeMappings = new Dictionary() { {".svg", "image/svg+xml"}, {".version", "text/plain"} }; - private readonly Dictionary CacheMappings = new Dictionary() + private static readonly Dictionary CacheMappings = new Dictionary() { {".svg", "no-cache"} }; @@ -138,7 +138,7 @@ public async Task CheckIfBlobExistsAsync(string blobPath) => await GetBlob(blobPath).ExistsAsync().ConfigureAwait(false); - private BlobHttpHeaders GetBlobHeadersByExtension(string filePath) + public static BlobHttpHeaders GetBlobHeadersByExtension(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) {