Pode icon indicating copy to clipboard operation
Pode copied to clipboard

file upload, IIS host

Open fr0mtheinternet opened this issue 1 year ago • 1 comments

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?

fr0mtheinternet avatar Jan 29 '24 14:01 fr0mtheinternet

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!

Badgerati avatar Jan 30 '24 21:01 Badgerati