Set Content-Type on transferred objects so .m4a is served as audio/mp4
This commit is contained in:
@@ -122,18 +122,27 @@ namespace Musify.Infrastructure.Services
|
|||||||
var key = string.Join('/', new[] { route, fileName }
|
var key = string.Join('/', new[] { route, fileName }
|
||||||
.Where(static s => !string.IsNullOrWhiteSpace(s))
|
.Where(static s => !string.IsNullOrWhiteSpace(s))
|
||||||
.Select(static s => s.Trim().Trim('/', '\\')));
|
.Select(static s => s.Trim().Trim('/', '\\')));
|
||||||
|
var contentType = MimeUtility.GetMimeMapping(filePath);
|
||||||
var upload = new Upload
|
var upload = new Upload
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
Bucket = bucket,
|
Bucket = bucket,
|
||||||
Key = key,
|
Key = key,
|
||||||
ContentType = MimeUtility.GetMimeMapping(filePath)
|
ContentType = contentType
|
||||||
};
|
};
|
||||||
await database.Uploads.AddAsync(upload, cancellationToken);
|
await database.Uploads.AddAsync(upload, cancellationToken);
|
||||||
|
|
||||||
try
|
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;
|
upload.State = UploadState.Successful;
|
||||||
successCount++;
|
successCount++;
|
||||||
logger.LogDebug("Transferred file to S3 {Bucket}/{Key}", bucket, key);
|
logger.LogDebug("Transferred file to S3 {Bucket}/{Key}", bucket, key);
|
||||||
|
|||||||
Reference in New Issue
Block a user