07-13-2022 08:32 AM - edited 07-13-2022 08:37 AM
HI to all,
I'm currently looking for a solution on how to store in a database field the content of a folder.
my idea is to compress the folder I want to store into the db into a zip file... then read the zip file like a text file and store the resulting string.
by now the main problem is to convert the zip file I create to a string and back.
if I simply read the zip file and re-write it into another zip file i obtain that the second file is corrupted.
my guess is that I'm not able to properly read the zip file... does anyone have advice?
Solved! Go to Solution.
07-13-2022 08:42 AM
I'd be interested in seeing some code. Because what you described should be possible. As long as the database can store nulls without treating it like a string I think you should be fine. It will just end up being an array of bytes that you can read, save to a temp location, and then open as a normal zip. I'm interested in seeing how you are reading and writing the zip file. Are you using the read from text file? Do you have Convert EOL on these nodes? They are on by default and can modify your read or write. The Read/Write binary file might be a better option. Also maybe compare the string value in the database, to the hex representation of the zip file before storing it. How are they different?
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-13-2022 08:59 AM
here is my unit test code
basically i select a folder and the vi creates a zip file "original" (which is not corrupted) then the vi tries to read the zip as a text and then re build a new zip file... which is corrupted😓
07-13-2022 11:14 AM
Can't see your code, 21 is too new for me.
Is Convert EOL off (right click the file function used to read and write)?
07-13-2022 11:19 AM
07-13-2022 11:20 AM
convert EOL is on
07-13-2022 02:56 PM - edited 07-13-2022 02:57 PM
@francescofabbro wrote:
convert EOL is on
That’s wrong! Disable it or use the Read Binary and Write Binary File functions instead!
A ZIP is a binary stream formaf and should never be read and written in text mode.
07-13-2022 03:25 PM
If you use "Write to binary file" remember to always turn off "prepend array or string size", otherwise you get 4 bytes at the front you weren't expecting.
07-14-2022 12:55 AM
hi,
I tried to put on false that input but nothing changes.
can it be a matter of encoding?
07-14-2022 03:34 AM
ZIP files are binary. There is no character encoding involved at any stage as far as the overall structure of a ZIP file is involved. There are text elements inside ZIP archives that COULD involve encoding but they have no influence on the level you are working here.
Try to not just see if the strings (really byte arrays but in LabVIEW these are unfortunately still the same things) are the same, but where they actually differ. Length, what bytes are different and so on. That will give you (or at least us) a clue to what might be the problem.