Initial work on upload app server
This commit is contained in:
@@ -12,3 +12,19 @@ export function readableFromWeb (body: ReadableStream<Uint8Array>): Readable {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return Readable.fromWeb(body as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a `fetch` init that streams `body` as the request body.
|
||||
*
|
||||
* Node's fetch refuses a stream body unless `duplex: 'half'` is set, but that
|
||||
* option is absent from the DOM `RequestInit` the project's `lib` resolves
|
||||
* to, so it has to go on behind a cast.
|
||||
*/
|
||||
export function streamingRequestInit (init: RequestInit, body: Readable): RequestInit {
|
||||
return {
|
||||
...init,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
body: Readable.toWeb(body) as any,
|
||||
duplex: 'half'
|
||||
} as RequestInit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user