Skip to content

Instantly share code, notes, and snippets.

@nikitaeverywhere
Last active March 30, 2017 18:04
Show Gist options
  • Save nikitaeverywhere/1b43e647f158136564560b02a80880b0 to your computer and use it in GitHub Desktop.
Save nikitaeverywhere/1b43e647f158136564560b02a80880b0 to your computer and use it in GitHub Desktop.
/// Original: https://github.com/eduard93/Utils/blob/master/Utils/REST.cls.xml
Class Utils.REST Extends %CSP.REST
{
XData UrlMap
{
<Routes>
<Route Url="/file" Method="GET" Call="GET"/>
</Routes>
}
ClassMethod GET()
{
set name = "Z:\icons.woff"
quit ..serve(name)
}
ClassMethod serve(name) As %Status
{
#dim sc As %Status = $$$OK
#dim %response As %CSP.Response
kill %request.Data
set %request.Data("STREAMOID",1)= ##class(%CSP.StreamServer).Encrypt(##class(%CSP.StreamServer).GetOidForFile(name))
if ##class(%CSP.StreamServer).OnPreHTTP() {
set %response.Headers("Content-Disposition")="attachment; filename*=UTF-8''" _ ##class(%CSP.Page).EscapeURL(name, "UTF8")
set sc = ##class(%CSP.StreamServer).OnPage()
}
quit sc
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment