feat: 添加媒体资产上传初始化和完成相关API接口及数据结构
This commit is contained in:
57
backend/app/http/tenant/dto/media_asset_admin.go
Normal file
57
backend/app/http/tenant/dto/media_asset_admin.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
// AdminMediaAssetUploadInitForm defines payload for tenant-admin to initialize a media asset upload.
|
||||
type AdminMediaAssetUploadInitForm struct {
|
||||
// Type is the media asset type (video/audio/image).
|
||||
// Used to decide processing pipeline and validation rules; required.
|
||||
Type string `json:"type,omitempty"`
|
||||
// ContentType is the MIME type reported by the client (e.g. video/mp4); optional.
|
||||
// Server should not fully trust it, but can use it as a hint for validation/logging.
|
||||
ContentType string `json:"content_type,omitempty"`
|
||||
// FileSize is the expected file size in bytes; optional.
|
||||
// Used for quota/limit checks and audit; client may omit when unknown.
|
||||
FileSize int64 `json:"file_size,omitempty"`
|
||||
// SHA256 is the hex-encoded sha256 of the file; optional.
|
||||
// Used for deduplication/audit; server may validate it later during upload-complete.
|
||||
SHA256 string `json:"sha256,omitempty"`
|
||||
}
|
||||
|
||||
// AdminMediaAssetUploadInitResponse returns server-generated upload parameters and the created asset id.
|
||||
type AdminMediaAssetUploadInitResponse struct {
|
||||
// AssetID is the created media asset id.
|
||||
AssetID int64 `json:"asset_id"`
|
||||
// Provider is the storage provider identifier (e.g. s3/minio/oss/local); for debugging/audit.
|
||||
Provider string `json:"provider,omitempty"`
|
||||
// Bucket is the target bucket/container; for debugging/audit (may be empty in stub mode).
|
||||
Bucket string `json:"bucket,omitempty"`
|
||||
// ObjectKey is the server-generated object key/path; client must NOT choose it.
|
||||
ObjectKey string `json:"object_key,omitempty"`
|
||||
|
||||
// UploadURL is the URL the client should upload to (signed URL or service endpoint).
|
||||
UploadURL string `json:"upload_url,omitempty"`
|
||||
// Headers are additional headers required for upload (e.g. signed headers); optional.
|
||||
Headers map[string]string `json:"headers,omitempty"`
|
||||
// FormFields are form fields required for multipart form upload (S3 POST policy); optional.
|
||||
FormFields map[string]string `json:"form_fields,omitempty"`
|
||||
// ExpiresAt indicates when UploadURL/FormFields expire; optional.
|
||||
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||||
}
|
||||
|
||||
// AdminMediaAssetUploadCompleteForm defines payload for tenant-admin to mark a media upload as completed.
|
||||
// This endpoint is expected to be called after the client finishes uploading the object to storage.
|
||||
type AdminMediaAssetUploadCompleteForm struct {
|
||||
// ETag is the storage returned ETag (or similar checksum); optional.
|
||||
// Used for audit/debugging and later integrity verification.
|
||||
ETag string `json:"etag,omitempty"`
|
||||
// ContentType is the MIME type observed during upload; optional.
|
||||
// Server may record it for audit and later processing decisions.
|
||||
ContentType string `json:"content_type,omitempty"`
|
||||
// FileSize is the uploaded object size in bytes; optional.
|
||||
// Server records it for quota/audit and later validation.
|
||||
FileSize int64 `json:"file_size,omitempty"`
|
||||
// SHA256 is the hex-encoded sha256 of the uploaded object; optional.
|
||||
// Server records it for integrity checks/deduplication.
|
||||
SHA256 string `json:"sha256,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user