async downloadStream()

in gh-actions-artifact-client/src/download-http-client.js [11:46]


  async downloadStream(name, outputStream) {
    const artifacts = await this.listArtifacts()
    if (artifacts.count === 0) {
      throw new Error(
        `Unable to find any artifacts for the associated workflow`
      )
    }
    const artifactToDownload = artifacts.value.find(artifact => {
      return artifact.name === name
    })
    if (!artifactToDownload) {
      throw new Error(`Unable to find an artifact with the name: ${name}`)
    }
    const partNameRegex = new RegExp(`${name}/part\\d+`)
    const items = await this.getContainerItems(
      artifactToDownload.name,
      artifactToDownload.fileContainerResourceUrl
    )
    const entries = items.value
      .filter(entry => {
        return entry.path.match(partNameRegex)
      })
      .sort((a, b) => a.path.localeCompare(b.path))
    const downloadSpecification =
      download_specification.getDownloadSpecification(name, entries, '', false)
    if (downloadSpecification.filesToDownload.length === 0) {
      console.error(
        `No downloadable files were found for the artifact: ${artifactToDownload.name}`
      )
    } else {
      await this.downloadSingleArtifactToStream(
        downloadSpecification.filesToDownload,
        outputStream
      )
    }
  }