Question
Guilherme Emmerick · Sep 23, 2020

How to get a .cls file in a server directory and download it to the client side

I need to get a file in a directory and when clicking on the download button, this file will be downloaded on the client side.

</head>
<csp:class super="%CSP.Page,Relatorio.GeraCSV">
<body> <input type="button" value="Gera Relatório" onClick="#server(..serve())#"> </body>

 

ClassMethod serve() As %Status
{
set name = "C:\Users\gpemm\Desktop\myfile.csv"
    #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(##class(%File).GetFilename(name), "UTF8")
        set sc = ##class(%CSP.StreamServer).OnPage()     }     quit sc
}

https://community.intersystems.com/post/uploading-and-downloading-files-...

I've tried this something I saw in a post here, but I didn't succeed

00
0 2 85 3

Replies

Try serving files from

<IRIS>\mgr\Temp\

directory.

By default InterSystems IRIS runs under system account which does not have access to your user account folders.

Didn't work, thanks anyway