LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP Post a TDMS file 8.2

Hi, I have already HTTP posted strings with Labview 7.1 & 8.2.

 

I need to now post a file - TDMS format to a server. I can find little bits of info on what is required, but not the full picture. Has anyone managed to do this?

 

I have included a packet sniffer output of an upload (another application which uploads TDMS files) and you can see where the TDMS file is inserted - "Content-Type: application/octet-stream"

 

What I am looking for is the file format being used, it looks like the TDMS file is read and appended - which I get, but what file format is being used? If I read the same TDMS file using READ FROM BINARY FILE.vi I get a similar output (but not identical). I think its just a formatting issue, so if anyone has manged to do this in 7.1 or 8.2 I would appreciate any info.

 

Paul.

0 Kudos
Message 1 of 5
(3,671 Views)

Hello Paul,

I have found a very useful link for you that explains TDMS file formats well. : https://www.ni.com/en/support/documentation/supplemental/07/tdms-file-format-internal-structure.html

 

I hope this will help you! 

 

Kind regards

0 Kudos
Message 2 of 5
(3,540 Views)

Hi, I have a look at your text file. I don't think this is a format issue. I only found many extra linefeed(0x0A) codes among the TDMS file contents. I think you should remove these codes when generating the http post

0 Kudos
Message 3 of 5
(3,522 Views)

A TDMS file is just like any other file - so if you figure out how to POST a simple text file you'll be able to send a TDMS file. In newer versions of LabVIEW this is relatively straightforward as the HTTP VIs have an option to provide a file path and transmit a file.

 

If you're rolling your own with an older version of LabVIEW...

 

The key is learn about multi-part form data (Content-Type: multipart/form-data) and then how to include your file as a section in the body of the http request. There's some more information here: http://stackoverflow.com/questions/8659808/how-does-http-file-upload-work

 

Be aware of file upload sizes using HTTP POST though - a lot of servers have limits on the maximum size of the POST data, the size of individual files and the maximum time a file upload can take.

 

I'm not sure where the extra line feed characters would be coming from - are you doing anything else with the file data after reading it?


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 5
(3,507 Views)

Hi, many thanks for all the reply's. I had actually got this working recently and did intend to update this thread.

 

First of all I tried using .txt files with base64 encoding - and found the contents also required to be decoded inside the .txt file once downloaded from the server, so that ruled out an encoding issue.

 

What I tried next was to do a simple read file.vi on the .txt file and post the contents, this worked - all the formatting (/r/n) seemed to be ok - I think I got caught up in the sniffer format too long, if I had used the native ascii labview read I would have been ok. What confused me was the difference between the files when read with Labview and the packet sniffer - I ruled this out when I checked the file again using a different packet sniffer as the same file appeared to be different again.

 

Next in case was a word .doc - this too was a sucess. Then I tried a .tdms file - and it was ok.

 

So, in short - if I just read the file from Labview (read file .vi) and pass this into the multi part content it works just fine. No encoding required!

 

If anyone is interested further I could eleborate.....and post the code.

 

Thanks again for the replies - very much apprciated - and on the money!

 

(This is a solution for Labview 7.1 & 8.2 )

0 Kudos
Message 5 of 5
(3,489 Views)