Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created November 26, 2019 13:38
Show Gist options
  • Save adamdriscoll/4da118ca9b321602e2fac4c477beb2af to your computer and use it in GitHub Desktop.
Save adamdriscoll/4da118ca9b321602e2fac4c477beb2af to your computer and use it in GitHub Desktop.
Upload a file via REST API in UD
Get-UDRestApi | Stop-UDRestApi
$Endpoint = New-UDEndpoint -AcceptFileUpload -Url "/process" -Method "POST" -Endpoint {
param($File)
Write-UDLog "GOT A FILE!"
$filepath = "C:\temp\dev\testdash\"
$filename = New-Item -Path $filepath -Name "$(get-random).txt"
if (!($File)) {
throw "file is empty."
}
Set-Content -Path $filename -Value $File -Encoding Byte
Write-UDLog "POST REQUEST reccieved, with FILE"
}
Start-UDRestApi -Endpoint $Endpoint -Port 8083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment