Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Download Asset File

view on GitHub

Download File is available as both a pgutil command and an HTTP Request, and will return the file as content, allowing the file to be downloaded.

Command Specification (CLI)

The assets download command is used to download a file from the asset directory.

The--path and --output options are always required. The --feed option is required if there is no default feed configured.

Downloading a file requires the asset directory (e.g. MyAssetDirectory), the path of the file (e.g. test-files/info.txt) and the output path to download to (e.g. C:\Inedo\test-files):

pgutil assets download --feed=myAssetDirectory --path=test-files/info.txt --output=C:\Inedo\test-files

HTTP Request Specification

To return the content a file, GET to the URL with the AssetDirectoryName, the file path, and an appropriate API key.

GET /endpoints/«AssetDirectoryName»/content/«path_to_file»

To return only the headers of a file, simply HEAD to the URL with the AssetDirectoryName, the file path, and an appropriate API key.

HEAD /endpoints/«AssetDirectoryName»/content/«path_to_file»

HTTP Response Specification

A successful 200 response to a GET or HEAD request will contain the file headers. A 401 response indicates a missing, unknown, or unauthorized API Key.

Sample Usage Scripts

Download all files in a folder (Powershell)

This script downloads all files within an asset directory, internal-files from a folder, download-files, to a local folder, C:\Proget\DownloadedFiles:

$baseUrl = "http://proget.corp.local"
$assetDirectory = "internal-files"
$assetFolder = "download-files"
$apiKey = "pra1b2c3d4e5oget"
$localFolder = "C:\ProGet\DownloadedFiles"

if (-not (Test-Path -Path $localFolder -PathType Container)) {
    New-Item -Path $localFolder -ItemType Directory | Out-Null
}

$listApiEndpoint = "$baseUrl/endpoints/$assetDirectory/dir/$assetFolder" + "?recursive=false"
$downloadApiEndpoint = "$baseUrl/endpoints/$assetDirectory/content/$assetFolder/"

$headers = @{"X-ApiKey" = $apiKey}

function Download-File {
    param (
        [string]$fileUrl,
        [string]$localFilePath
    )

    try {
        Invoke-WebRequest -Uri $fileUrl -OutFile $localFilePath -Headers $headers -ErrorAction Stop
        Write-Host "Downloaded: $($localFilePath | Split-Path -Leaf)"
    } catch {
        Write-Host "Failed to download: $($localFilePath | Split-Path -Leaf). $_"
    }
}

try {
    $listResponse = Invoke-RestMethod -Uri $listApiEndpoint -Method Get -Headers $headers

    if ($listResponse.Count -gt 0) {
        foreach ($fileInfo in $listResponse) {
            $fileName = $fileInfo.name
            $fileDownloadUrl = $fileInfo.content
            $completeDownloadUrl = $downloadApiEndpoint + $fileName
            $localFilePath = Join-Path $localFolder $fileName
            Download-File -fileUrl $completeDownloadUrl -localFilePath $localFilePath
        }

        Write-Host "All files downloaded successfully."
    } else {
        Write-Host "The folder is empty"
    }
} catch {
    Write-Host "Failed to retrieve the list of files. $_"
}