( source: Readable, headers: IncomingHttpHeaders )
| 34 | * @since 4.0.0 |
| 35 | */ |
| 36 | export const stream = ( |
| 37 | source: Readable, |
| 38 | headers: IncomingHttpHeaders |
| 39 | ): Stream.Stream<Multipart.Part, Multipart.MultipartError> => |
| 40 | Multipart.makeConfig(headers as any).pipe( |
| 41 | Effect.map((config) => |
| 42 | NodeStream.fromReadable<MP.Part, Multipart.MultipartError>({ |
| 43 | evaluate() { |
| 44 | const parser = MP.make(config) |
| 45 | source.pipe(parser) |
| 46 | return parser as any |
| 47 | }, |
| 48 | onError: (error) => convertError(error as any) |
| 49 | }) |
| 50 | ), |
| 51 | Stream.unwrap, |
| 52 | Stream.map(convertPart) |
| 53 | ) |
| 54 | |
| 55 | /** |
| 56 | * Parses multipart data from a Node readable request body and persists file |
no test coverage detected