( file: RawFileInput, requestId: string, logger: Logger )
| 751 | * @throws Error if file is an array or has no storage key |
| 752 | */ |
| 753 | export function processSingleFileToUserFile( |
| 754 | file: RawFileInput, |
| 755 | requestId: string, |
| 756 | logger: Logger |
| 757 | ): UserFile { |
| 758 | if (Array.isArray(file)) { |
| 759 | const errorMsg = `Expected a single file but received an array with ${file.length} file(s). Use a file input that accepts multiple files, or select a specific file from the array (e.g., {{block.files[0]}}).` |
| 760 | logger.error(`[${requestId}] ${errorMsg}`) |
| 761 | throw new Error(errorMsg) |
| 762 | } |
| 763 | |
| 764 | const userFile = convertToUserFile(file, requestId, logger) |
| 765 | if (!userFile) { |
| 766 | const errorMsg = `File has no storage key: ${file.name || 'unknown'}` |
| 767 | logger.warn(`[${requestId}] ${errorMsg}`) |
| 768 | throw new Error(errorMsg) |
| 769 | } |
| 770 | |
| 771 | return userFile |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * Converts raw file objects to UserFile format, accepting single or array input |
no test coverage detected