implement new Download-FileDirectly function to handle downloads
This commit is contained in:
@@ -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 {
|
||||
<#
|
||||
|
||||
Reference in New Issue
Block a user