node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.
MIT License
7.01k stars 680 forks source link

fileWriteStreamHandler accept promise which will resolve to writeable stream #785

Closed dcvice1967 closed 2 years ago

dcvice1967 commented 2 years ago

Support plan

Context

What problem are you trying to solve?

We need to store file contents from the form data in a blob in the oracle database. When the fileWriteStreamHandler is called, we need to open a db connection and request a blob handle. This handle is wrapped as a writable stream. Since these calls return promises, we need to have the fileWriteStreamHandler support receiving a promise which will resolve to the writeable stream. Currently this does not seem to be supported.

Do you have a new or modified API suggestion to solve the problem?

Either add a new property for promised based callback or update the existing one to check if the result is a promise and handle accordingly.

GrosSacASac commented 2 years ago

Can you try to convert the promise into a stream ? With this library https://github.com/GrosSacASac/stream-sac/blob/main/source/concatAsStream.js

const stream = concatAsStream([promise]);