1
0
Fork 0

add explicit options

vmjoseph/download-v4-client-blob
srryan 2023-12-19 11:49:39 -05:00
parent bf93b54558
commit 73babeabef
1 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,7 @@ import {
} from '../../generated'
import {getBackendIdsFromToken} from '../shared/util'
import {ArtifactNotFoundError} from '../shared/errors'
import {BlobClient} from '@azure/storage-blob'
import {BlobClient, BlobDownloadOptions} from '@azure/storage-blob'
const scrubQueryParameters = (url: string): string => {
const parsed = new URL(url)
@ -41,14 +41,20 @@ async function exists(path: string): Promise<boolean> {
async function streamExtract(url: string, directory: string): Promise<void> {
const blobClient = new BlobClient(url)
const response = await blobClient.download()
core.info(util.inspect(blobClient))
core.info(util.inspect(response))
const options: BlobDownloadOptions = {
maxRetryRequests: 3,
abortSignal: undefined,
onProgress: (progress) => core.debug(`Download progress: ${progress.loadedBytes}`)
}
const response = await blobClient.download(0, 0, options)
return new Promise((resolve, reject) => {
response.readableStreamBody
?.pipe(unzip.Extract({path: directory}))
.on('close', resolve)
.on('error', reject)
.on('aborted', reject)
})
}