From e3b7a0353e862d544595b080a0d7cd083f99bca9 Mon Sep 17 00:00:00 2001 From: XShine555 Date: Tue, 2 Jun 2026 19:26:45 +0200 Subject: [PATCH] Set Content-Type on transferred objects so .m4a is served as audio/mp4 --- Infrastructure/Services/StorageService.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Infrastructure/Services/StorageService.cs b/Infrastructure/Services/StorageService.cs index 3a97ee5..b07c765 100644 --- a/Infrastructure/Services/StorageService.cs +++ b/Infrastructure/Services/StorageService.cs @@ -122,18 +122,27 @@ namespace Musify.Infrastructure.Services var key = string.Join('/', new[] { route, fileName } .Where(static s => !string.IsNullOrWhiteSpace(s)) .Select(static s => s.Trim().Trim('/', '\\'))); + var contentType = MimeUtility.GetMimeMapping(filePath); var upload = new Upload { Id = Guid.NewGuid(), Bucket = bucket, Key = key, - ContentType = MimeUtility.GetMimeMapping(filePath) + ContentType = contentType }; await database.Uploads.AddAsync(upload, cancellationToken); try { - await trasnsferUtility.UploadAsync(filePath, bucket, key, cancellationToken); + await trasnsferUtility.UploadAsync( + new TransferUtilityUploadRequest + { + FilePath = filePath, + BucketName = bucket, + Key = key, + ContentType = contentType + }, + cancellationToken); upload.State = UploadState.Successful; successCount++; logger.LogDebug("Transferred file to S3 {Bucket}/{Key}", bucket, key);