namespace TakeoutSaaS.Module.Storage.Models;

/// <summary>
/// 对象存储上传请求参数。
/// </summary>
/// <remarks>
/// 初始化上传请求。
/// </remarks>
/// <param name="objectKey">对象键（含路径）。</param>
/// <param name="content">文件流。</param>
/// <param name="contentType">内容类型。</param>
/// <param name="contentLength">内容长度。</param>
/// <param name="generateSignedUrl">是否返回签名访问链接。</param>
/// <param name="signedUrlExpires">签名有效期。</param>
/// <param name="metadata">附加元数据。</param>
public sealed class StorageUploadRequest(
    string objectKey,
    Stream content,
    string contentType,
    long contentLength,
    bool generateSignedUrl,
    TimeSpan signedUrlExpires,
    IDictionary<string, string>? metadata = null)
{
    /// <summary>
    /// 对象键。
    /// </summary>
    public string ObjectKey { get; } = objectKey;

    /// <summary>
    /// 文件流。
    /// </summary>
    public Stream Content { get; } = content;

    /// <summary>
    /// 内容类型。
    /// </summary>
    public string ContentType { get; } = contentType;

    /// <summary>
    /// 内容长度。
    /// </summary>
    public long ContentLength { get; } = contentLength;

    /// <summary>
    /// 是否需要签名访问链接。
    /// </summary>
    public bool GenerateSignedUrl { get; } = generateSignedUrl;

    /// <summary>
    /// 签名有效期。
    /// </summary>
    public TimeSpan SignedUrlExpires { get; } = signedUrlExpires;

    /// <summary>
    /// 元数据集合。
    /// </summary>
    public IReadOnlyDictionary<string, string> Metadata { get; } = metadata == null
            ? new Dictionary<string, string>()
            : new Dictionary<string, string>(metadata);
}
