NewFileProcessor 创建文件处理器
()
| 40 | |
| 41 | // NewFileProcessor 创建文件处理器 |
| 42 | func NewFileProcessor() *FileProcessor { |
| 43 | return &FileProcessor{ |
| 44 | supportedFormats: []string{ |
| 45 | ".txt", ".md", ".html", ".htm", // 现有格式 |
| 46 | ".pdf", // PDF |
| 47 | ".ppt", ".pptx", // PowerPoint |
| 48 | ".doc", ".docx", // Word |
| 49 | ".xls", ".xlsx", // Excel |
| 50 | ".csv", ".json", ".xml", // Text-based formats |
| 51 | ".epub", // EPub |
| 52 | // 音频格式支持阿里云通义听悟API |
| 53 | ".mp3", ".wav", ".m4a", ".wma", ".aac", ".ogg", ".amr", ".flac", ".aiff", |
| 54 | // 视频格式也可以转音频 |
| 55 | ".mp4", ".wmv", ".m4v", ".flv", ".rmvb", ".dat", ".mov", ".mkv", ".webm", ".avi", ".mpeg", ".3gp", |
| 56 | ".pcm", ".opus", ".speex", // 实时音频流格式 |
| 57 | }, |
| 58 | lightweightFormats: []string{".txt", ".md"}, // md, txt 文件不保存原始文件 |
| 59 | heavyweightFormats: []string{".html", ".htm"}, // html 文件需要完整保护 |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // isLightweightFile 判断是否为轻量级文件 |
| 64 | func (fp *FileProcessor) isLightweightFile(filename string) bool { |
no outgoing calls
no test coverage detected