LabVIEW Web UI Builder and Data Dashboard

cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos
Message 1 of 28
(8,605 Views)

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?

0 Kudos
Message 2 of 28
(8,603 Views)

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
0 Kudos
Message 3 of 28
(8,539 Views)

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.

Message 4 of 28
(8,528 Views)

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.

0 Kudos
Message 5 of 28
(8,524 Views)

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...

0 Kudos
Message 6 of 28
(8,516 Views)

Thanks Greg,

 

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

 

-Adam.

Adam Amos | CPE Systems
aamos@cpesys.com.au
0 Kudos
Message 7 of 28
(8,505 Views)

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.

0 Kudos
Message 8 of 28
(8,496 Views)

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

0 Kudos
Message 9 of 28
(8,491 Views)

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.

 

 

Message 10 of 28
(8,484 Views)