cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

FileRepository CreateZipArchive service - separator for filelist?

MB_10406376
2-Explorer

FileRepository CreateZipArchive service - separator for filelist?

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!

 

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

6 REPLIES 6
PaiChung
22-Sapphire I
(To:MB_10406376)

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.

PaiChung
22-Sapphire I
(To:MB_10406376)

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.

Mark_B
2-Explorer
(To:smainente)

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

Announcements


Top Tags