Skip to content

buildTimestampedOssObjectPath

生成带时间戳与随机后缀的 OSS 对象路径:{prefix}/{timestamp}-{random}.{ext}

函数签名

typescript
function buildTimestampedOssObjectPath(
  prefix: string,
  fileName: string,
  fallbackExt: string,
): string

使用场景

  • 社区图片/封面、短视频等直传前生成唯一对象键
  • 避免各端重复实现 Date.now() + 随机串 + 扩展名校验逻辑