CodeArtifact - how to download a package using AWS PowerShell

0

I have figured how to download a package from CodeArtifact using AWS CLI but we are very much a PowerShell shop. This is how I tried to download a package using PowerShell:

$buildPackage = Get-CAPackageVersionAsset -Asset MyApp.3.55.31.zip -Domain my-packages -DomainOwner <my-account-id> -Format generic -Namespace my-namespace -Package MyApp -PackageVersion 3.55.31 -Repository my-builds
$buildPackage

That returns an object like this Asset AssetName PackageVersion PackageVersionRevision


Amazon.Runtime.Internal.Util.CachingWrapperStream MyApp.3.55.31.zip 3.55.31 <revision-id>

I've tried to get the package from the Stream but there are too many methods - I just can't see how to do it.

Anyone have experience with this?

demandé il y a 6 mois237 vues
1 réponse
0

I played around with downloading from the returned stream and got this to work:

$buildPackage = Get-CAPackageVersionAsset -Asset MyAsset.3.55.98.zip -Domain mydomain -DomainOwner <aws_account_id> -Format generic -Namespace mynamespace -Package MyAsset -PackageVersion 3.55.98 -Repository myrepo

    $ms = New-Object System.IO.MemoryStream
    $buildPackage.Asset.CopyTo($ms)
    $bytes = $ms.ToArray()
    [IO.File]::WriteAllBytes($DownloadPath, $bytes)
répondu il y a 5 mois
profile picture
EXPERT
vérifié il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions