July 2018
Beginner
552 pages
13h 18m
English
The read method will let users either list all files or get the content of one specific file. So, we will need to create a new GET route. The data is returned in a JSON structure as well. Take a look at the following example, within which the new route that delivers a list of file objects is created:
New-PolarisGetRoute -Path "/files" -Scriptblock { $gciParameters = @{ Path = $Request.PolarisPath Filter = '*' ErrorAction = 'SilentlyContinue' } $gciParameters.Filter = if ($request.Query['Name']) { $request.Query['Name'] } elseif ($request.Body.Name) { $request.Body.Name } $files = Get-ChildItem @gciParameters | Select-Object -Property @{Name = 'Name'; Expression = {$_.Name}},@{Name = 'Content'; Expression = {$_ | Get-Content -Raw}} $Response.Send(($files ...Read now
Unlock full access