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?

已提問 6 個月前檢視次數 237 次
1 個回答
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)
已回答 5 個月前
profile picture
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南