Hi experts,
we use this service as described in Article - CS259031 (ThingWorx 9.1.14) but in some cases, there are files with a comma in its filename. This throws an exception like "JavaException: java.lang.Exception: Some files listed are not readable: [/24043033da000.iam/0, 7.ipt]". The real filename is "0,7.ipt" (without blank).
The comma is used as separator like in the given example to create the list of filenames in var params. So is there any other way create this list without relying on special characters allowed for filenames? We need this feature because we want to exclude specific files from the list to be not included in ZipArchive.
Any proposal appreciated - Thanks!
Solved! Go to Solution.
CreateZipArchive tries to split the files param using ';' (main list separator) and then if it fails ',' (alternative list separator).
The following syntax is working for me:
// result: BOOLEAN
let result = Things["SystemRepository"].CreateZipArchive({
path: "/" /* STRING */,
newFileName: "output.zip" /* STRING */,
files: "/a,5.txt;" /* STRING */
});
My concern is that this syntax is not documented - we will report to RD so that they don't change the behavior in the future.
Not sure when that comes up, but perhaps you can reconstruct those filenames using escape characters and then read it?
Thanks for your answer. Not sure, if I understood correctly, but renaming the files is not an option, as there are references to filenames within the (binary) content of other files in the zip container (CAD product data, like CREO, Catia, Inventor, STEP, ...).
And - just verified - the same exception is thrown in TWX Version 9.3.
Escape characters should allow you to use the actual name, I'm not talking about renaming files, but a way to refer to the file names properly in code by utilizing escape characters.
CreateZipArchive tries to split the files param using ';' (main list separator) and then if it fails ',' (alternative list separator).
The following syntax is working for me:
// result: BOOLEAN
let result = Things["SystemRepository"].CreateZipArchive({
path: "/" /* STRING */,
newFileName: "output.zip" /* STRING */,
files: "/a,5.txt;" /* STRING */
});
My concern is that this syntax is not documented - we will report to RD so that they don't change the behavior in the future.
Thank you very much for this valuable hint! The first test was successful, but now I need to check that we don't have files with ';' in their name (this would be weird). An update of the above mentioned article ("How to use the FileRepository CreateZipArchive ...") would be helpful for the next newbie anyway. Where do I find the "official" documentation for this (and similar) methods?
Semicolons are valid filename characters on both *nix and Windows systems, so you can theoretically have both ; and , in the filenames. Just in case you have to handle those, one workaround would be to use FileTransferSubsystem to copy all files into a temporary directory one by one, then zip the entire directory, then cleanup.
/ Constantine