- 20 Dec 2023
- 1 Minute to read
- Print
- DarkLight
- PDF
Import Archive Endpoint
- Updated on 20 Dec 2023
- 1 Minute to read
- Print
- DarkLight
- PDF
The Import Archive is an endpoint in ProGet's Asset Directory API. It adds the contents of an uploaded archive in zip
or tar
format to the specified path.
This example imports an archive, development-files.zip
to a folder development
, authenticating with the API key abc12345
:
curl -X POST -H "X-ApiKey: abc12345" --data-binary "@C:\ProGet\development-files.zip" "https://proget.corp.local/endpoints/internal-files/import/development?format=zip&overwrite=true"
The format
argument may be either zip
(for a zip file) or tgz
(for a GZipped tar file). When overwrite
is false
or not specified, items already in the asset directory will never be overwritten. When overwrite
is true
, items in the asset directory will be overwritten. If the specified folder does not exist, it will be created.
Request Specification
To import an archive, simply POST
to the URL with the AssetDirectoryName
, path to the folder and the format.
POST /endpoints/«AssetDirectoryName»/import/«path_to_folder»?format=«zip/tgz»&overwrite=«true/false»
Importing an archive requires the asset directory name (e.g. myAssetDirectory
), the folder name to be populated, (e.g. myFolder
) and the format of the imported archive (e.g. zip
)
POST /endpoints/myAssetDirectory/import/myFolder?format=zip&overwrite=true
«contents of imported-archive.zip»
Response Specification
Response | Details |
---|---|
200 (Success) | the contents of the archive is uploaded to the asset directory |
400 (Invalid Format) | indicates that the format is invalid |
401 (Authentication Required) | indicates a missing, unknown, or unauthorized API Key |
Sample Usage Scripts
Upload multiple archives (Powershell)
This script uploads all archives (zip
or tgz
) in a folder, C:\Proget\development-files
and creates a folder for each based on the name of the archive:
$apiKey = "a1b2c3d4e5"
$folderPath = "C:\Proget\development-files"
$baseUrl = "https://proget.corp.local"
$assetDirectory = "internal-files"
$headers = @{
"X-ApiKey" = $apiKey
}
$fileList = Get-ChildItem -Path $folderPath -File | Where-Object { $_.Extension -eq ".zip" -or $_.Extension -eq ".tgz" }
foreach ($file in $fileList) {
$folderName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
$dynamicEndpoint = "$baseUrl/endpoints/$assetDirectory/import/$folderName"
$response = Invoke-RestMethod -Uri $dynamicEndpoint -Method Post -Headers $headers -InFile $file.FullName -ContentType "application/octet-stream"
Write-Host "Uploaded $($file.Name)"
Write-Host $response
}