File Downloads with Server Connect

You can create a file download action in Server Connect, which allows you to download files from your server. You can use static or dynamic file names for the download action, so it can easily be used in cases where you need to export data (csv/xml) and download the exported file, download zip archives or any other file.
In this tutorial we will show you the basics of file download action.

Download File Server Action

First, open the Server Connect panel:

Create new server action:

We call it download. Right click Steps:

Open File Management and select File Download:

Select the path to your file. This can be dynamic or static, so if you have some dynamic action returning the path to your file, select it here:

In our case this is a static path, so we just browse to the file and select it:

Save your server action:

Server Connect Routing

You can directly link to your server action, browsing to the file in the dmxConnect/api/.. folder, but we suggest using routing instead. It’s easier to add the link to the server action on the page later and does not directly expose the link to the server action.

Open the Routing panel:

Create a new Server Connect Route:

Select your download action and click the Select button:

It automatically sets the routing path to /api/server_action_name but you can change it to whatever you like. We are just fine with this path, so we leave it as it is:

We are done with this part.

Adding Download Link to Your Page

Close the routing panel and open the App Connect Panel:

On our page you can see an anchor button, but this also works with a regular link. Select your link/anchor button and click the Route Picker icon for the link:

Select the route to the download server action and click the Select button:

Save your page and we are done. Here’s the result:


@Teodor this is working great, is it possible to add to the Download File action step the following parameters?

  • The file name to be displayed to the user (it could be different from the actual file name export.csv)
  • Ability to force Download or Inline or Prompt (content-type)

@Teodor Is it possible to share a bit more info about server connect routing? Or at least a link with a bit more info or use cases. Thanks.

@pixlapps it works exactly as page routing.
One of the use cases is the one described here, where you need to add file downloads. Another would be some API action requiring login/redirect, so in short - any action that would require you to link directly to it via link/anchor is easier to be selected via the routing picker.

Also - if you want to provide server action’s results directly to the user, just as any API data source does it’s easier to have the link like: instead of

1 Like

@Teodor I guess this will also make mobile apps easier in terms of connections with the backend or API’s.

8 posts were split to a new topic: File download with dynamic link