export const standardHeaderKeys = ['content-type', 'cache-control', 'content-disposition', 'content-encoding', 'content-language', 'expires']; export type StandardHeaders = { ContentType?: string; CacheControl?: string; ContentDisposition?: string; ContentEncoding?: string; ContentLanguage?: string; Expires?: Date; }; /** * 从元数据中提取标准头部和自定义元数据 * @param metaData 原始元数据 * @returns 标准头部和自定义元数据 */ export function extractStandardHeaders(metaData: Record): { standardHeaders: StandardHeaders; customMetadata: Record; } { const standardHeaders: StandardHeaders = {}; const customMetadata: Record = {}; for (const [key, value] of Object.entries(metaData)) { const lowerKey = key.toLowerCase(); if (lowerKey === 'content-type') { standardHeaders.ContentType = value; } else if (lowerKey === 'cache-control') { standardHeaders.CacheControl = value; } else if (lowerKey === 'content-disposition') { standardHeaders.ContentDisposition = value; } else if (lowerKey === 'content-encoding') { standardHeaders.ContentEncoding = value; } else if (lowerKey === 'content-language') { standardHeaders.ContentLanguage = value; } else if (lowerKey === 'expires') { standardHeaders.Expires = new Date(value); } else { customMetadata[key] = value; } } return { standardHeaders, customMetadata }; }