Page 1 of 1

How get the path of a file to download it.

PostPosted: Wed Apr 27, 2022 6:15 pm
by jean
Hi,

I'm trying to get the path of a file so that can be downloaded, like pulgins.file.openFile does, but not triggering, I just want the path as: http://localhost:8183/resources/dynamic ... clientnr=2. Sol this can be use on img tag or a tag for download for example. What I'm trying to achieve here? I just want to expose this file so people can download it. Ideally I would have something like: http://servername/download/filename.extension.

Thank you!

Re: How get the path of a file to download it.

PostPosted: Wed Apr 27, 2022 6:31 pm
by patrick
If that file resides on the server, have a look at plugins.file.getUrlForRemoteFile(jsFile)

Re: How get the path of a file to download it.

PostPosted: Tue May 17, 2022 3:14 pm
by Joas
jean wrote:Ideally I would have something like: http://servername/download/filename.extension.

http://servername points to the ROOT-folder of your tomcat installation, so you could create a download-folder in there and move your files to that folder.

Not sure if you're aware of this, but in the application you can just use
Code: Select all
plugins.file.writeFile(fileName, bytes)
to push the file as a download.

Re: How get the path of a file to download it.

PostPosted: Wed May 18, 2022 8:47 pm
by mboegem
patrick wrote:If that file resides on the server, have a look at plugins.file.getUrlForRemoteFile(jsFile)


I know Servoy has a function exposed in the API to directly write bytes to a temporary file on the server, and directly returning the URL
Is that something which could be exposed within Servoy as well?

Now you have to create a temp file first, seems twice the i/o to me.