Pode
Pode copied to clipboard
file upload, IIS host
Question
I'm struggling with uploading files, and was hoping for some pointers. The server is operating behind IIS.
Here's the server.ps1:
Import-Module -Name Pode
Start-PodeServer {
Add-PodeEndpoint -Address 127.0.0.1 -Protocol Http
Enable-PodeSessionMiddleware -Duration 120 -Extend
Add-PodeAuthIIS -Name 'IISAuth' -NoGroups
Add-PodeRoute -Method Get -Path '/' -ScriptBlock {
Write-PodeJsonResponse -Value @{ Message = "Hello, World!" }
}
Add-PodeRoute -Method Post -Path '/upload' -ScriptBlock {
Save-PodeRequestFile -Key 'upload'
}
}
And here's the upload request:
$cred = get-credential
Invoke-WebRequest -Uri "https://server.full.url/upload" -Method Post -Form @{ upload = (Get-Item .\text.txt)} -Credential $cred
The Get routes work fine, but the post above is throwing a 500 for http://server.full.url/upload (note the unencrypted URL).
Is it some issue with IIS passing the file along?
Hi @fr0mtheinternet,
If you add the following line within Start-PodeServer to enable error logging, and then restart your site:
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
When the 500 is thrown again, there should be a /logs folder where your .ps1 is located. Is there any error messages in there? Could sometimes take a couple seconds to appear.
Thanks!