Is it possible in LabVIEW web services to transmit a binary file to the client (to be downloaded) in response to a HTTP Request? For example map a URL as /download/filename to download the file to local computer?
If you are programmatically creating the data in LabVIEW then the LabVIEW Web Development Community has an example that lets you See an Image of the Front Panel on the Web using LabVIEW Web Services which may be helpful for you.
Here are the key things to point out:
Alternatively, if the file is just a static file saved on disk and you want to be able to share it there is a help topic that describes Integrating Static Content into a Web Service.
Thanks Milan for your response. I am trying to get a filename from the client, and then send an AVI file with that name that is stored on the server PC to the client. I've followed your suggestion, and the code is like this:
The VI is also set as RESTful Web Method VI with stream output, using headers and buffered. When I send a request through client, it creates a file with the right filename in the download folder but the file size is zero. What am I doing wrong? By the way, I cannot statically refer to the file, because these files are programetically created and managed.
I am looking into this use case closer. To make sure I understand what is going wrong, you are saying that you are trying to be able to post a file name from the Client, have the Server read that file name, find the file on the Server, and then send it to the Client? And as of it's current state, it seems to work in the sense that a file is being created on the Client under "downloads" but that there is no data in that file?
Also, how large of files are you trying to send to the Client? Also have you looked into using a TCP connection to send the file?
Applications Engineer | National Instruments
That's right. The files are going to be around ~5 MB. I will not have any program installed on the client machine, except the normal windows programs, i.e. I'll have the web browser, but cannot make a new program in LabVIEW and install it on the client. Not sure how I can do this with TCP connection.
1) Are you getting any errors in the Webservice VI?
You can set a breakpoint in the VI, run the webservice as debug, hit the page from the browser, and step through each VI to see if errors occur on the wire.
2) Do you see the same behavior in multiple web browsers?
4) Try the more generic MIME Type 'application/octet-stream'
5) I vaguely remember having issues in some cases using the Set HTTP Response MIME Type VI with streaming output. If the above is not helping try replacing the Set HTTP Response MIME Type VI with the Set HTTP Header VI with the header input 'Content-Type' and header value to the MIME Type