How get the path of a file to download it.

Questions, answers, tips and ideas on Servoy Client

How get the path of a file to download it.

Postby jean » Wed Apr 27, 2022 6:15 pm

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!
jean
 
Posts: 2
Joined: Mon Mar 14, 2022 4:18 pm

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

Postby patrick » Wed Apr 27, 2022 6:31 pm

If that file resides on the server, have a look at plugins.file.getUrlForRemoteFile(jsFile)
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

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

Postby Joas » Tue May 17, 2022 3:14 pm

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.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

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

Postby mboegem » Wed May 18, 2022 8:47 pm

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.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Servoy Client

Who is online

Users browsing this forum: No registered users and 14 guests