Polaris icon indicating copy to clipboard operation
Polaris copied to clipboard

Support for file upload/download

Open Glober777 opened this issue 8 years ago • 2 comments

It would be quite handy to have some simple built in support for file download and upload

Glober777 avatar Oct 16 '17 19:10 Glober777

So, download and upload are of course built-in to httplistener but are we talking about built-in to the directory browser for static files from a directory or just documentation on how to do it?

Tiberriver256 avatar Dec 17 '18 20:12 Tiberriver256

Yes, it will be good if we have a option to download files like

Import-Module Polaris -Verbose
New-PolarisStaticRoute -RoutePath "/MyFile" -FolderPath "./downloads" 

New-PolarisGetRoute -Path "/" -ScriptBlock {
    $Response.Send("Hello World!")
}
Start-Polaris -Port 1337 
Start-Process "chrome.exe" "http://localhost:1337"

So, users can place a link or button to download the file

PS C:\> http://localhost:1337/MyFile/File1.Json

To get this working - I made a minor change in the New-PolarisStaticRoute cmdlet like illustrated below

$Response.Headers.Add('Content-Disposition', "attachment;filename=$($RequestedItem.Name)")
                $Response.SetStream(
                    [System.IO.File]::OpenRead($RequestedItem.FullName)
                )

Blog Link for Reference

@TylerLeonhardt @Tiberriver256 - Let me know your input

ChendrayanV avatar Apr 10 '19 09:04 ChendrayanV