< Back

Write-PodeFileResponse

Sat Jan 18, 2020 7:21 pm

NAME Write-PodeFileResponse



SYNOPSIS

Renders the content of a static, or dynamic, file on the Response.





SYNTAX

Write-PodeFileResponse [-Path] <String> [[-Data] <Object>] [[-ContentType] <String>] [[-MaxAge] <Int32>]

[[-StatusCode] <Int32>] [-Cache] [<CommonParameters>]





DESCRIPTION

Renders the content of a static, or dynamic, file on the Response.

You can set browser's to cache the content, and also override the file's content type.





PARAMETERS

-Path <String>

The path to a file.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Data <Object>

A HashTable of dynamic data to supply to a dynamic file.



Required? false

Position? 2

Default value @{}

Accept pipeline input? false

Accept wildcard characters? false



-ContentType <String>

The content type of the file's contents - this overrides the file's extension.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-MaxAge <Int32>

The maximum age to cache the file's content on the browser, in seconds.



Required? false

Position? 4

Default value 3600

Accept pipeline input? false

Accept wildcard characters? false



-StatusCode <Int32>

The status code to set against the response.



Required? false

Position? 5

Default value 200

Accept pipeline input? false

Accept wildcard characters? false



-Cache [<SwitchParameter>]

Should the file's content be cached by browsers, or not?



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Write-PodeFileResponse -Path 'C:/Files/Stuff.txt'













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Write-PodeFileResponse -Path 'C:/Files/Stuff.txt' -Cache -MaxAge 1800













-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Write-PodeFileResponse -Path 'C:/Files/Stuff.txt' -ContentType 'application/json'













-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Write-PodeFileResponse -Path 'C:/Views/Index.pode' -Data @{ Counter = 2 }













-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Write-PodeFileResponse -Path 'C:/Files/Stuff.txt' -StatusCode 201















RELATED LINKS