<< Click to Display Table of Contents >> RayFlow PowerShell API > 7.3 > Implementation Guide > Working with RayFlow PowerShell API Downloading Files |
To download files from RayFlow, first you need to define a PowerShell object, which will be the container for files attached to a selected phase or task. After that, use Start-RayFlowFileDownload to invoke web request and subsequent download to a local folder.
This command let supports both single file as a parameter, or many files at once. You can use this property to quickly download all attachments for interesting task, for example the script below download all files in package PKG-000006:
$phase = $project | Get-RayFlowPhase -PhaseName EVAL;
$task = $phase | Get-RayFlowTask -TaskHumanFriendlyId PKG-000006;
Start-RayFlowFileDownload $task.Files -TargetFolder "C:\Downloads"
This will download all files to the C:\Downloads folder, and the results will be passed to the output, so that they can be piped by subsequent commands:
# Below is output of Start-RayFlowFileDownload. There may be more items here!
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11.02.2017 08:00 9211904 cdbxp_setup_x64_4.5.7.6499.msi
If you omit the -TargetFolder parameter, the file will be downloaded to a temporary location %Temp%\RayFlowDownloads. Since the results are piped, you can read the exact path by accessing the FullName property from the output:
$file = Start-RayFlowFileDownload -File $task[0].Files
Write-Host $file.FullName;
C:\Users\user\AppData\Local\Temp\RayFlowDownloads\cdbxp_setup_x64_4.5.7.6499.msi