Force contentType from the headers to be .png, .jpeg or .jpg
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Storage.Blobs;
|
||||
using Azure.Storage.Blobs.Models;
|
||||
@@ -16,7 +13,6 @@ public class AzureBlobStorageService : IAzureBlobStorageService
|
||||
private readonly ILogger<AzureBlobStorageService> _logger;
|
||||
private readonly long _maxUploadSize = 10 * 1024 * 1024; // 10 MB in bytes
|
||||
|
||||
|
||||
public AzureBlobStorageService(IConfiguration configuration, ILogger<AzureBlobStorageService> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -47,6 +43,13 @@ public class AzureBlobStorageService : IAzureBlobStorageService
|
||||
throw new InvalidOperationException($"Blob storage: File size exceeds the maximum allowed size of {_maxUploadSize} bytes.");
|
||||
}
|
||||
|
||||
// Validate content type
|
||||
if (!ContentTypes.IsAllowed(contentType))
|
||||
{
|
||||
_logger.LogInformation($"Blob storage: Unsupported file type {contentType}. Only PNG and JPEG are allowed.");
|
||||
throw new InvalidOperationException("Unsupported file type. Only PNG and JPEG are allowed.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get a reference to a container
|
||||
|
||||
Reference in New Issue
Block a user