File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1- { "engineHash" : " d1cb68d " , "specHash" : " 9919482" , "version" : " 1.3.0" }
1+ { "engineHash" : " ab2fc63 " , "specHash" : " 9919482" , "version" : " 1.3.0" }
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ export function decodeBase64ByteStream(data: string): Readable {
186186 : eval ( 'require' ) ( 'stream' ) . Readable . from ( Buffer . from ( data , 'base64' ) ) ;
187187}
188188
189- export async function readByteStream ( byteStream : Readable ) {
189+ export async function readByteStream ( byteStream : Readable ) : Promise < Buffer > {
190190 const buffers : Buffer [ ] = [ ] ;
191191 for await ( const data of byteStream ) {
192192 buffers . push ( data ) ;
Original file line number Diff line number Diff line change @@ -226,8 +226,15 @@ export async function fetch(
226226 options
227227 )
228228 : options ;
229-
230- const requestInit = await createRequestInit ( fetchOptions ) ;
229+ const fileStreamBuffer = fetchOptions . fileStream
230+ ? await readByteStream ( fetchOptions . fileStream )
231+ : void 0 ;
232+ const requestInit = await createRequestInit ( {
233+ ...fetchOptions ,
234+ fileStream : fileStreamBuffer
235+ ? generateByteStreamFromBuffer ( fileStreamBuffer )
236+ : void 0 ,
237+ } ) ;
231238
232239 const { params = { } } = fetchOptions ;
233240 const response = await nodeFetch (
@@ -287,7 +294,13 @@ export async function fetch(
287294 await fetchOptions . auth . refreshToken ( fetchOptions . networkSession ) ;
288295
289296 // retry the request right away
290- return fetch ( resource , { ...fetchOptions , numRetries : numRetries + 1 } ) ;
297+ return fetch ( resource , {
298+ ...fetchOptions ,
299+ numRetries : numRetries + 1 ,
300+ fileStream : fileStreamBuffer
301+ ? generateByteStreamFromBuffer ( fileStreamBuffer )
302+ : void 0 ,
303+ } ) ;
291304 }
292305
293306 const isRetryable =
You can’t perform that action at this time.
0 commit comments