name: 设计媒体策略 description: 设计媒体和数字资产管理(DAM)架构,包括存储、处理和交付。覆盖图像、视频和文档。 argument-hint: [–scope 图像|视频|文档|所有] [–storage azure|aws|本地] allowed-tools: 读取、全局、查找、任务、技能、询问用户问题
设计媒体策略命令
设计一个全面的媒体和数字资产管理(DAM)架构。
用法
/cms:设计媒体策略 --scope 所有
/cms:设计媒体策略 --scope 图像 --storage azure
/cms:设计媒体策略 --scope 视频 --storage aws
范围选项
- 图像:图像存储、优化、交付
- 视频:视频托管、转码、流媒体
- 文档:PDF、Office文档、下载
- 所有:完整的媒体策略
工作流程
步骤1:解析参数
从命令中提取范围和存储提供商。
步骤2:收集需求
使用询问用户问题来了解:
- 预期的媒体量是多少?
- 是否有特定的格式要求?
- 有哪些CDN/交付要求?
- 是否有合规/安全需求(水印、访问控制)?
步骤3:调用代理
调用 cms-advisor media-strategy 代理进行全面分析。
步骤4:生成存储架构
Azure Blob 存储配置:
storage:
provider: azure_blob
containers:
- name: cms-media-originals
access: 私有
purpose: 原始上传文件
retention: 无限期
- name: cms-media-processed
access: 私有
purpose: 处理/转换后的文件
retention: 30天未使用
- name: cms-media-public
access: blob # 公共读取,私有列表
purpose: 公共CDN服务的资产
cdn: true
lifecycle_rules:
- name: archive-old-originals
condition:
days_since_modification: 365
action: move_to_cool
- name: delete-temp
prefix: temp/
condition:
days_since_creation: 7
action: delete
security:
encryption: AES256
https_only: true
sas_tokens:
enabled: true
max_duration: 1_hour
AWS S3 配置:
storage:
provider: aws_s3
buckets:
- name: cms-media-originals
region: us-east-1
versioning: true
- name: cms-media-processed
region: us-east-1
intelligent_tiering: true
cloudfront:
enabled: true
price_class: PriceClass_100
origins:
- bucket: cms-media-processed
path: /public/*
behaviors:
- path: /images/*
compress: true
cache_ttl: 86400
- path: /videos/*
streaming: true
步骤5:设计处理管道
图像处理:
image_pipeline:
upload:
max_size: 50MB
allowed_types: [jpg, jpeg, png, gif, webp, svg, avif]
scan_for_malware: true
extract_metadata: true
processing:
profiles:
thumbnail:
width: 150
height: 150
fit: cover
format: webp
quality: 80
small:
width: 400
height: 300
fit: contain
format: webp
quality: 85
medium:
width: 800
height: 600
fit: contain
format: webp
quality: 85
large:
width: 1600
height: 1200
fit: contain
format: webp
quality: 90
hero:
width: 1920
height: 1080
fit: cover
format: webp
quality: 90
focal_point: true
responsive_breakpoints:
- 320
- 640
- 768
- 1024
- 1280
- 1920
formats:
modern: [avif, webp]
fallback: jpg
optimization:
strip_metadata: true
progressive: true
preserve_color_profile: sRGB
视频处理:
video_pipeline:
upload:
max_size: 5GB
allowed_types: [mp4, mov, avi, webm, mkv]
transcoding:
provider: azure_media_services # 或 aws_mediaconvert
profiles:
web_hd:
codec: h264
resolution: 1080p
bitrate: 5000kbps
audio: aac_128
web_sd:
codec: h264
resolution: 720p
bitrate: 2500kbps
audio: aac_128
mobile:
codec: h264
resolution: 480p
bitrate: 1000kbps
audio: aac_96
adaptive_streaming:
enabled: true
protocols: [hls, dash]
thumbnails:
count: 10
interval: auto
sprite_sheet: true
文档处理:
document_pipeline:
upload:
max_size: 100MB
allowed_types: [pdf, doc, docx, xls, xlsx, ppt, pptx]
processing:
pdf:
generate_preview: true
extract_text: true
page_thumbnails: true
office:
convert_to_pdf: true
extract_metadata: true
security:
virus_scan: true
password_detection: true
步骤6:设计资产元数据模型
EF Core 模型:
public class MediaAsset
{
public Guid Id { get; set; }
public string FileName { get; set; }
public string ContentType { get; set; }
public long FileSize { get; set; }
public string StoragePath { get; set; }
public MediaAssetType Type { get; set; }
public MediaStatus Status { get; set; }
// 提取的元数据(JSON列)
public MediaMetadata Metadata { get; set; }
// 处理后的变体
public List<MediaVariant> Variants { get; set; }
// DAM功能
public List<string> Tags { get; set; }
public string AltText { get; set; }
public string Caption { get; set; }
public string Copyright { get; set; }
public FocalPoint FocalPoint { get; set; }
// 审计
public Guid UploadedById { get; set; }
public DateTime UploadedAt { get; set; }
}
[Owned]
public class MediaMetadata
{
// 图像元数据
public int? Width { get; set; }
public int? Height { get; set; }
public string ColorSpace { get; set; }
// 视频元数据
public TimeSpan? Duration { get; set; }
public string Codec { get; set; }
public int? Bitrate { get; set; }
// 文档元数据
public int? PageCount { get; set; }
public string Author { get; set; }
public string Title { get; set; }
// EXIF数据
public DateTime? DateTaken { get; set; }
public string CameraModel { get; set; }
public GeoLocation Location { get; set; }
}
[Owned]
public class FocalPoint
{
public decimal X { get; set; } // 0-1
public decimal Y { get; set; } // 0-1
}
步骤7:生成CDN配置
Azure Front Door:
cdn:
provider: azure_front_door
endpoints:
- name: media
origin: cms-media-public.blob.core.windows.net
rules:
- name: images
match:
path: /images/*
actions:
cache_ttl: 7_days
compression: true
- name: transform
match:
path: /transform/*
actions:
origin_override: image-transform-function.azurewebsites.net
security:
waf: enabled
rate_limiting: 1000/minute
geo_filtering:
allowed: [US, CA, EU]
API端点
api:
upload:
- POST /api/media/upload
- POST /api/media/upload/chunk (用于大文件)
retrieve:
- GET /api/media/{id}
- GET /api/media/{id}/variants
- GET /api/media/{id}/download
transform:
- GET /media/transform/{id}?w=800&h=600&fit=cover&format=webp
search:
- GET /api/media?tags=product&type=image
manage:
- PATCH /api/media/{id}/metadata
- DELETE /api/media/{id}
相关技能
media-asset-management- DAM模式image-optimization- 响应式图像cdn-media-delivery- CDN配置