Updates
This commit is contained in:
@@ -6,12 +6,6 @@ namespace Fragalytics.Web.Services;
|
||||
|
||||
public sealed class ClipMediaService
|
||||
{
|
||||
private static readonly HashSet<string> AllowedExtensions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
".mp4",
|
||||
".webm"
|
||||
};
|
||||
|
||||
private readonly JsonAppStore _store;
|
||||
private readonly FragalyticsOptions _options;
|
||||
|
||||
@@ -29,9 +23,9 @@ public sealed class ClipMediaService
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var extension = Path.GetExtension(fileName);
|
||||
if (!AllowedExtensions.Contains(extension))
|
||||
if (!ClipMediaFormats.AllowedExtensions.Contains(extension))
|
||||
{
|
||||
throw new InvalidOperationException("Only .mp4 and .webm clip uploads are supported.");
|
||||
throw new InvalidOperationException($"Only {ClipMediaFormats.Mp4Extension} and {ClipMediaFormats.WebMExtension} clip uploads are supported.");
|
||||
}
|
||||
|
||||
var clipsDirectory = Path.Combine(Path.GetFullPath(_options.DataDirectory), "clips");
|
||||
@@ -69,22 +63,16 @@ public sealed class ClipMediaService
|
||||
ClipJobId = clipJobId,
|
||||
FileName = safeFileName,
|
||||
StoredPath = storedPath,
|
||||
ContentType = string.IsNullOrWhiteSpace(contentType) ? InferContentType(extension) : contentType,
|
||||
ContentType = string.IsNullOrWhiteSpace(contentType) ? ClipMediaFormats.InferContentType(extension) : contentType,
|
||||
FileSizeBytes = fileSize
|
||||
};
|
||||
|
||||
state.ClipAssets.Add(asset);
|
||||
clipJob.ClipAssetId = asset.Id;
|
||||
clipJob.Status = "rendered";
|
||||
clipJob.Status = ClipJobStatuses.Rendered;
|
||||
clipJob.ErrorMessage = null;
|
||||
clipJob.CompletedAtUtc = DateTime.UtcNow;
|
||||
return asset.Id;
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private static string InferContentType(string extension) => extension.ToLowerInvariant() switch
|
||||
{
|
||||
".webm" => "video/webm",
|
||||
_ => "video/mp4"
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user