NI Home > Community > NI Discussion Forums

LabVIEW Web UI Builder and Data Dashboard

Reply
Member
Daniel Stoilkov
Posts: 15
0 Kudos

How can i make hyperlink to local file for dowloading

How can I make hyperlink to a local file for downloading it, it seams that only www links work in web Ui.

Thanks

Member
GregR
Posts: 134
0 Kudos

Re: How can i make hyperlink to local file for dowloading

I'm not sure what you're asking for. By local do you mean local to the server or local to the client? When I hear "hyperlink to a local file", I tend to think of a "file://" url. But if the file is on the user's machine, then they don't need to download it.

 

Are you really trying to access a file on the user's machine or are you trying to give them a link that prompts to save the file locally? For the latter, is the file static content that you could just publish to your web server or will its contents change over time?

Member
Adam_Amos
Posts: 13
0 Kudos

Re: How can i make hyperlink to local file for dowloading

Hi,

 

I am also interested in this functionality.

 

I would like the user to be able to download logging files (.txt) from my cRIO target.

 

Is this possible with HTTP commands via the Web UI builder?

 

-Adam

Adam Amos | CPE Systems
aamos@cpesys.com.au
Member
GregR
Posts: 134

Re: How can i make hyperlink to local file for dowloading

If we assume that you have a LabVIEW application running on your cRIO that is exposing some data through web services, there are a couple of possibilities.

 

You can create a web service call that returns the log data. In order for the browser to treat this as a file, you must set the correct content type in the http header. To do this you can't use the default form of data output. Instead you must create an "httpRequestID" input to your web service VI. With this you can call "Write Response.vi" to give the log data and "Set HTTP Header.vi" to specify the type (text/text probably works for a log). You can look at "examples\comm\webservices\address book\FindContacts.vi" to see an example of calling these 2 VIs. Once you create that web service entry point, you can set that as the URL of the hyperlink control and it should work.

 

Another option is to have the cRIO application write to a log file that is under the root of the web server running on the machine. (This is the same place the xap for your Web UI Builder application is put.) This file could then be served up through the web server just like any other file.

 

With either of these solutions there may be concerns about the browser caching results rather than requesting new content each time. There are additional values that can be set in the http headers with the first solution that can help with this, but I think there is still some variation between browsers.

Member
GregR
Posts: 134
0 Kudos

Re: How can i make hyperlink to local file for dowloading

I dug a little more and actually created a sample VI. The VI shows returning a dynamic log through a web service and using the "Content-disposition" header to tell the browser to prompt for a location to save. In order to use this approach to return the data, you must configure the VI to the "Stream" output type when adding it as a service VI in your build spec.

Active Participant X.
Active Participant
X.
Posts: 1,822
0 Kudos

Re: How can i make hyperlink to local file for dowloading

Any chance that solution can be extended to reading/writing files on the machine running the WebUI code? In other words, provide the equivalent of a read/write function to access files on the machine on which the WebUI code runs? I understand that there are built-in browser safety features that make this a big no-no, but we are not talking about writing Trojans or Viruses here...

Member
Adam_Amos
Posts: 13
0 Kudos

Re: How can i make hyperlink to local file for downloading

Thanks Greg,

 

I will have a look shortly and let you know how i go.

 

-Adam.

Adam Amos | CPE Systems
aamos@cpesys.com.au
Member
GregR
Posts: 134
0 Kudos

Re: How can i make hyperlink to local file for downloading

We could do some limited file support. It just didn't make the cut. Because of the limits of Silverlight security, the user would have to be prompted for the file each time. You can't even programmatically provide a suggested location or file name. So as long as every open is interactive, basic reads and writes can be supported.

Active Participant X.
Active Participant
X.
Posts: 1,822
0 Kudos

Re: How can i make hyperlink to local file for downloading

Interactive open/save capabilities would cut it for me at this stage.

Active Participant
JoshuaP
Posts: 820

Re: How can i make hyperlink to local file for downloading

You can probaby add the following section to the end of the /ni-rt/system/webserver/NISystemWebServer.conf

 

#
# Share the files over http
#
Alias "/files" "./../../.."
<Directory "./../../..">
</Directory>

 

Then reboot the target.

 

That should allow you to use a simple HTTP Get to pull files off the target using a url like http://hostname:3580/files/ni-rt.ini.  Just note that you won't be able to browse directories, but if you know the path you should be able to pull off the data files.  You can also limit the scope to which files are shared by changing the directory path.  The one specified above opens everything up.