Update

The update method lets users update the contents of a specific file. The payload for our PUT route is again JSON containing the name and contents of the file, as seen in the following example:

New-PolarisPutRoute -Path "/files" -Scriptblock {
if (-not $request.Body.Name -or -not $request.Body.Content)
{
$response.SetStatusCode(501)
$response.Send("File name and file content may not be empty.")
return
}

[void] (Set-Content -Path (Join-Path $Request.PolarisPath $request.Body.Name) -Value $request.Body.Content)
} -Force

Like the create method, the update method examines the request and returns a 501 error when the filename and contents are not set.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.9.115