feat(upload): add image format conversion and quality settings for uploads #6

This commit is contained in:
shiyu
2025-05-23 20:10:09 +08:00
parent c6cc7cc777
commit b26b076736
10 changed files with 438 additions and 132 deletions

View File

@@ -1,16 +1,30 @@
using System.ComponentModel.DataAnnotations;
using Foxel.Models.DataBase;
using Foxel.Models.Enums;
using Foxel.Services.Attributes;
namespace Foxel.Models.Request.Picture;
public record UploadPictureRequest
{
[Required] public IFormFile File { get; set; } = null!;
[Required(ErrorMessage = "文件不能为空")]
public IFormFile File { get; set; } = null!;
public int? Permission { get; set; } = 1;
[Range(0, 2, ErrorMessage = "权限类型必须是0公开、1私有或2仅关注者")]
public int? Permission { get; set; } = 0;
public int? AlbumId { get; set; } = null;
public StorageType? StorageType { get; set; } = null;
public int? AlbumId { get; set; }
public StorageType? StorageType { get; set; }
/// <summary>
/// 目标图片格式,默认为保持原格式
/// </summary>
public ImageFormat ConvertToFormat { get; set; } = ImageFormat.Original;
/// <summary>
/// 图片质量仅对JPEG和WebP有效1-100
/// </summary>
[Range(1, 100, ErrorMessage = "图片质量必须在1-100之间")]
public int Quality { get; set; } = 95;
}