feat: finalize core modules and gateway
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
namespace TakeoutSaaS.Module.Storage.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 直传(预签名上传)请求参数。
|
||||
/// </summary>
|
||||
public sealed class StorageDirectUploadRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化请求。
|
||||
/// </summary>
|
||||
/// <param name="objectKey">对象键。</param>
|
||||
/// <param name="contentType">内容类型。</param>
|
||||
/// <param name="contentLength">内容长度。</param>
|
||||
/// <param name="expires">签名有效期。</param>
|
||||
public StorageDirectUploadRequest(string objectKey, string contentType, long contentLength, TimeSpan expires)
|
||||
{
|
||||
ObjectKey = objectKey;
|
||||
ContentType = contentType;
|
||||
ContentLength = contentLength;
|
||||
Expires = expires;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 目标对象键。
|
||||
/// </summary>
|
||||
public string ObjectKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容类型。
|
||||
/// </summary>
|
||||
public string ContentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容长度。
|
||||
/// </summary>
|
||||
public long ContentLength { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 签名有效期。
|
||||
/// </summary>
|
||||
public TimeSpan Expires { get; }
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TakeoutSaaS.Module.Storage.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 直传(预签名上传)结果。
|
||||
/// </summary>
|
||||
public sealed class StorageDirectUploadResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 预签名上传地址(PUT 上传或表单地址)。
|
||||
/// </summary>
|
||||
public string UploadUrl { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 直传附加字段(如表单直传所需字段),PUT 方式为空。
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, string> FormFields { get; init; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// 预签名过期时间。
|
||||
/// </summary>
|
||||
public DateTimeOffset ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的对象键。
|
||||
/// </summary>
|
||||
public string ObjectKey { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 上传成功后可选的签名下载地址。
|
||||
/// </summary>
|
||||
public string? SignedDownloadUrl { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace TakeoutSaaS.Module.Storage.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 对象存储上传请求参数。
|
||||
/// </summary>
|
||||
public sealed class StorageUploadRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化上传请求。
|
||||
/// </summary>
|
||||
/// <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 StorageUploadRequest(
|
||||
string objectKey,
|
||||
Stream content,
|
||||
string contentType,
|
||||
long contentLength,
|
||||
bool generateSignedUrl,
|
||||
TimeSpan signedUrlExpires,
|
||||
IDictionary<string, string>? metadata = null)
|
||||
{
|
||||
ObjectKey = objectKey;
|
||||
Content = content;
|
||||
ContentType = contentType;
|
||||
ContentLength = contentLength;
|
||||
GenerateSignedUrl = generateSignedUrl;
|
||||
SignedUrlExpires = signedUrlExpires;
|
||||
Metadata = metadata == null
|
||||
? new Dictionary<string, string>()
|
||||
: new Dictionary<string, string>(metadata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对象键。
|
||||
/// </summary>
|
||||
public string ObjectKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件流。
|
||||
/// </summary>
|
||||
public Stream Content { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容类型。
|
||||
/// </summary>
|
||||
public string ContentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容长度。
|
||||
/// </summary>
|
||||
public long ContentLength { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要签名访问链接。
|
||||
/// </summary>
|
||||
public bool GenerateSignedUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 签名有效期。
|
||||
/// </summary>
|
||||
public TimeSpan SignedUrlExpires { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 元数据集合。
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, string> Metadata { get; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace TakeoutSaaS.Module.Storage.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 上传结果信息。
|
||||
/// </summary>
|
||||
public sealed class StorageUploadResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 对象键。
|
||||
/// </summary>
|
||||
public string ObjectKey { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 可访问的 URL(可能已包含签名)。
|
||||
/// </summary>
|
||||
public string Url { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 带过期时间的签名 URL(若生成)。
|
||||
/// </summary>
|
||||
public string? SignedUrl { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小。
|
||||
/// </summary>
|
||||
public long FileSize { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容类型。
|
||||
/// </summary>
|
||||
public string ContentType { get; init; } = string.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user