mirror of https://github.com/actions/toolkit
update to use blob client over http client
parent
68f22927e7
commit
571bf222ee
|
@ -17,6 +17,8 @@ import {
|
||||||
} from '../../generated'
|
} from '../../generated'
|
||||||
import {getBackendIdsFromToken} from '../shared/util'
|
import {getBackendIdsFromToken} from '../shared/util'
|
||||||
import {ArtifactNotFoundError} from '../shared/errors'
|
import {ArtifactNotFoundError} from '../shared/errors'
|
||||||
|
import {BlobClient, } from '@azure/storage-blob'
|
||||||
|
|
||||||
|
|
||||||
const scrubQueryParameters = (url: string): string => {
|
const scrubQueryParameters = (url: string): string => {
|
||||||
const parsed = new URL(url)
|
const parsed = new URL(url)
|
||||||
|
@ -38,18 +40,11 @@ async function exists(path: string): Promise<boolean> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function streamExtract(url: string, directory: string): Promise<void> {
|
async function streamExtract(url: string, directory: string): Promise<void> {
|
||||||
const client = new httpClient.HttpClient(getUserAgentString())
|
const blobClient = new BlobClient(url)
|
||||||
const response = await client.get(url)
|
const response = await blobClient.download()
|
||||||
|
|
||||||
if (response.message.statusCode !== 200) {
|
|
||||||
throw new Error(
|
|
||||||
`Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
response.message
|
response.readableStreamBody?.pipe(unzip.Extract({path: directory}))
|
||||||
.pipe(unzip.Extract({path: directory}))
|
|
||||||
.on('close', resolve)
|
.on('close', resolve)
|
||||||
.on('error', reject)
|
.on('error', reject)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue