@@ -50,33 +50,17 @@ export async function downloadArtifact(
5050 const headers = {
5151 Authorization : `Bearer ${ token } `
5252 }
53- const resp = await got ( req . url , {
54- headers,
55- followRedirect : false
56- } )
57-
58- core . info ( `Fetch artifact URL: ${ resp . statusCode } ${ resp . statusMessage } ` )
59- if ( resp . statusCode !== 302 ) {
60- throw new Error ( 'Fetch artifact URL failed: received unexpected status code' )
61- }
62-
63- const url = resp . headers . location
64- if ( url === undefined ) {
65- const receivedHeaders = Object . keys ( resp . headers )
66- core . info ( `Received headers: ${ receivedHeaders . join ( ', ' ) } ` )
67- throw new Error ( 'Location header was not found in API response' )
68- }
69- if ( typeof url !== 'string' ) {
70- throw new Error ( `Location header has unexpected value: ${ url } ` )
71- }
7253
73- const downloadStream = got . stream ( url , { headers} )
54+ const downloadStream = got . stream ( req . url , { headers} )
7455 const fileWriterStream = createWriteStream ( fileName )
7556
76- core . info ( `Downloading ${ url } ` )
57+ downloadStream . on ( 'redirect' , response => {
58+ core . info ( `Downloading ${ response . headers . location } ` )
59+ } )
7760 downloadStream . on ( 'downloadProgress' , ( { transferred} ) => {
7861 core . info ( `Progress: ${ transferred } B` )
7962 } )
63+
8064 await asyncStream ( downloadStream , fileWriterStream )
8165 } finally {
8266 core . endGroup ( )
0 commit comments