Multidragdrop control - zip file validation before saving it in the specified location
Hi All,
I have a requirement where we need to validate all the items(files) in the zip file when we just drag drop the zip file.
the validation is like to check if the file names inside the zip file has any special chars or not..
So, here first i tried to get the path of the file using the below piece of code:
ClipboardPage cpProcess = tools.findPage("pxProcess"); ClipboardPage myPage = tools.findPage("xxxx"); String exPath = cpProcess.getString("pxServiceExportPath");
String strZipFileName = tools.getParamValue("fileName");
String exPathFull =exPath+strZipFileName;
myPage.getProperty("pyFilePath").setValue(exPathFull); oLog.infoForced("File Uploaded path "+exPathFull);
After this i was able to see the below in the logs:
File Uploaded path file://web:/StaticContent/global/ServiceExport/specialcharsissuetest.zip
Now,when im trying to get the files in this zip file using the below code its not giving me anything
Hi All,
I have a requirement where we need to validate all the items(files) in the zip file when we just drag drop the zip file.
the validation is like to check if the file names inside the zip file has any special chars or not..
So, here first i tried to get the path of the file using the below piece of code:
ClipboardPage cpProcess = tools.findPage("pxProcess"); ClipboardPage myPage = tools.findPage("xxxx"); String exPath = cpProcess.getString("pxServiceExportPath");
String strZipFileName = tools.getParamValue("fileName");
String exPathFull =exPath+strZipFileName;
myPage.getProperty("pyFilePath").setValue(exPathFull); oLog.infoForced("File Uploaded path "+exPathFull);
After this i was able to see the below in the logs:
File Uploaded path file://web:/StaticContent/global/ServiceExport/specialcharsissuetest.zip
Now,when im trying to get the files in this zip file using the below code its not giving me anything
try{ ClipboardPage myPage = tools.findPage("xxx"); String exPath = myPage.getString("pyFilePath"); java.util.zip.ZipFile zipFile=new java.util.zip.ZipFile(exPath); java.util.Enumeration<? extends java.util.zip.ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { java.util.zip.ZipEntry entry = entries.nextElement(); String FileName= entry.getName(); if(FileName.endsWith(".msg")){ int idx=FileName.lastIndexOf("."); String FileNameWithoutExt =FileName.substring(0,idx); java.util.regex.Pattern p = java.util.regex.Pattern.compile("[^A-Za-z0-9]"); java.util.regex.Matcher m = p.matcher(FileNameWithoutExt); boolean b = m.find(); oLog.infoForced("path is next java "+exPath); oLog.infoForced("filename in the zip "+FileNameWithoutExt); //if b is true set the erroe message on clib board if(b==true){ myPage.getProperty("FailureMsg").setValue("Have special chars"); } } } zipFile.close(); }catch(Exception e){ //write error message to cliboard page
}
Please help me with what i m doing wrong and what i need to do to achieve this.
Thanks In advance.
***Edited by Moderator: Pallavi to update platform capability tags***