Remove committed media. Store and serve proper mime type.
parent
262e8cd468
commit
0fc8d756b3
|
@ -352,3 +352,5 @@ Upload/
|
|||
LANCommander/Icon/
|
||||
LANCommander/Settings.yml
|
||||
LANCommander/Saves/
|
||||
LANCommander/Media/
|
||||
LANCommander/Uploads/
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace LANCommander.Controllers.Api
|
|||
|
||||
var fs = System.IO.File.OpenRead(MediaService.GetImagePath(media));
|
||||
|
||||
return File(fs, "image/png");
|
||||
return File(fs, media.MimeType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace LANCommander.Data.Models
|
|||
[MaxLength(2048)]
|
||||
public string SourceUrl { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string MimeType { get; set; }
|
||||
|
||||
public Guid GameId { get; set; }
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(GameId))]
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 405 KiB |
Binary file not shown.
Before Width: | Height: | Size: 876 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.4 MiB |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LANCommander.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddMediaMimeType : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "MimeType",
|
||||
table: "Media",
|
||||
type: "TEXT",
|
||||
maxLength: 255,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MimeType",
|
||||
table: "Media");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -492,6 +492,11 @@ namespace LANCommander.Migrations
|
|||
b.Property<Guid>("GameId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("MimeType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SourceUrl")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
|
|
|
@ -9,5 +9,6 @@ namespace LANCommander.Models
|
|||
public string SourceUrl { get; set; }
|
||||
public string ThumbnailUrl { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
modalRef.Config.ConfirmLoading = true;
|
||||
|
||||
media.SourceUrl = result.SourceUrl;
|
||||
media.MimeType = result.MimeType;
|
||||
|
||||
if (media.Id == Guid.Empty)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,14 @@ namespace LANCommander.Services.MediaGrabbers
|
|||
public class SteamGridDBMediaGrabber : IMediaGrabberService
|
||||
{
|
||||
SteamGridDb SteamGridDb { get; set; }
|
||||
|
||||
private SteamGridDbFormats[] SupportedFormats = new SteamGridDbFormats[]
|
||||
{
|
||||
SteamGridDbFormats.Png,
|
||||
SteamGridDbFormats.Jpeg,
|
||||
SteamGridDbFormats.Webp
|
||||
};
|
||||
|
||||
public SteamGridDBMediaGrabber()
|
||||
{
|
||||
var settings = SettingService.GetSettings();
|
||||
|
@ -45,13 +53,14 @@ namespace LANCommander.Services.MediaGrabbers
|
|||
{
|
||||
var icons = await SteamGridDb.GetIconsByGameIdAsync(game.Id);
|
||||
|
||||
return icons.Select(i => new MediaGrabberResult()
|
||||
return icons.Where(i => SupportedFormats.Contains(i.Format)).Select(i => new MediaGrabberResult()
|
||||
{
|
||||
Id = i.Id.ToString(),
|
||||
Type = MediaType.Icon,
|
||||
SourceUrl = i.FullImageUrl,
|
||||
ThumbnailUrl = i.ThumbnailImageUrl,
|
||||
Group = game.Name
|
||||
Group = game.Name,
|
||||
MimeType = GetMimeType(i.Format)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,13 +68,14 @@ namespace LANCommander.Services.MediaGrabbers
|
|||
{
|
||||
var covers = await SteamGridDb.GetGridsByGameIdAsync(game.Id);
|
||||
|
||||
return covers.Select(c => new MediaGrabberResult()
|
||||
return covers.Where(c => SupportedFormats.Contains(c.Format)).Select(c => new MediaGrabberResult()
|
||||
{
|
||||
Id = c.Id.ToString(),
|
||||
Type = MediaType.Cover,
|
||||
SourceUrl = c.FullImageUrl,
|
||||
ThumbnailUrl = c.ThumbnailImageUrl,
|
||||
Group = game.Name
|
||||
Group = game.Name,
|
||||
MimeType = GetMimeType(c.Format)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,14 +83,30 @@ namespace LANCommander.Services.MediaGrabbers
|
|||
{
|
||||
var backgrounds = await SteamGridDb.GetHeroesByGameIdAsync(game.Id);
|
||||
|
||||
return backgrounds.Select(b => new MediaGrabberResult()
|
||||
return backgrounds.Where(b => SupportedFormats.Contains(b.Format)).Select(b => new MediaGrabberResult()
|
||||
{
|
||||
Id = b.Id.ToString(),
|
||||
Type = MediaType.Background,
|
||||
SourceUrl = b.FullImageUrl,
|
||||
ThumbnailUrl = b.ThumbnailImageUrl,
|
||||
Group = game.Name
|
||||
Group = game.Name,
|
||||
MimeType = GetMimeType(b.Format)
|
||||
});
|
||||
}
|
||||
|
||||
private string GetMimeType(SteamGridDbFormats format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case SteamGridDbFormats.Png:
|
||||
return "image/png";
|
||||
case SteamGridDbFormats.Jpeg:
|
||||
return "image/jpg";
|
||||
case SteamGridDbFormats.Webp:
|
||||
return "image/webp";
|
||||
default:
|
||||
throw new NotImplementedException("The SteamGridDB grabber currently does not support this format");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue