Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

set content type when write blob storage #1036

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class TemporaryExposureKeyBlobService : ITemporaryExposureKeyBlobService
const string batchNumberMetadataKey = "batch_number";
const string batchRegionMetadataKey = "batch_region";
const string fileNameSuffix = ".zip";
private readonly static string _contentTypeJson = @"application/json";
private readonly static string _contentTypeZip = @"application/zip";

public readonly string TekExportKeyUrl;
public readonly string TekExportBlobStorageConnectionString;
Expand Down Expand Up @@ -62,6 +64,10 @@ public async Task WriteToBlobAsync(Stream s, TemporaryExposureKeyExportModel mod
blockBlob.Metadata[batchNumberMetadataKey] = model.BatchNum.ToString();
blockBlob.Metadata[batchRegionMetadataKey] = model.Region;

if(blockBlob.Properties.ContentType != _contentTypeZip)
{
blockBlob.Properties.ContentType = _contentTypeZip;
}
await blockBlob.UploadFromStreamAsync(s);
Logger.LogInformation($" {nameof(WriteToBlobAsync)} upload {exportFileName}");
await blockBlob.SetMetadataAsync();
Expand Down Expand Up @@ -120,6 +126,10 @@ public async Task WriteFilesJsonAsync(IEnumerable<TemporaryExposureKeyExportMode
await writer.FlushAsync();
await stream.FlushAsync();
stream.Position = 0;
if (blockBlob.Properties.ContentType != _contentTypeJson)
{
blockBlob.Properties.ContentType = _contentTypeJson;
}
await blockBlob.UploadFromStreamAsync(stream);
}
}
Expand Down