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

Commit

Permalink
Merge pull request #1037 from cocoa-mhlw/fix/set_content_type_when_wi…
Browse files Browse the repository at this point in the history
…rte_blob_storage

refactoring
  • Loading branch information
cocoa-dev006 authored Jun 15, 2022
2 parents 1f95e85 + 6d799f8 commit 1e2fbb9
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Threading.Tasks;

namespace Covid19Radar.Background.Services
Expand All @@ -22,8 +23,6 @@ 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 @@ -64,9 +63,9 @@ public async Task WriteToBlobAsync(Stream s, TemporaryExposureKeyExportModel mod
blockBlob.Metadata[batchNumberMetadataKey] = model.BatchNum.ToString();
blockBlob.Metadata[batchRegionMetadataKey] = model.Region;

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

0 comments on commit 1e2fbb9

Please sign in to comment.