implement new Download-FileDirectly function to handle downloads

This commit is contained in:
2026-09-30 11:42:05 -04:00
parent 4e06ede640
commit 0975f5d24a
5 changed files with 79 additions and 31 deletions
+13
View File
@@ -209,6 +209,19 @@ Function Download-File {
Return $File
}
# Downloads from the original URL; BITS handles redirects without preliminary web requests.
# Without -File, the temporary filename comes from the original URL, not its redirect target.
Function Download-FileDirectly {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$URL,
[Parameter(Mandatory=$false,ValueFromPipeline=$false)][string]$File
)
If ( [string]::IsNullOrEmpty($File) ) { $File = '{0}{1}' -f (Get-TempPath), (Split-Path $URL -Leaf) }
Try { Start-BitsTransfer -Source $URL -Destination $File -ErrorAction Stop }
Catch { Throw "BITS download failed from ${URL} to ${File}: $($_.Exception.Message)" }
Return $File
}
# Upload a file to a LiquidFiles Filedrop and submit its notification message.
Function Upload-File {
<#