on 11-30-2011 9:44 AM
Dear Friends,
when i am trying upload the same image it is throughing error,to avoid it i want to add random number to the filr before its extension likeimage1.jpg and image2.jpg i am new to this please guide me to proceed .
Thanks,
Smruti Ranjan Moharana
can you share more ? what are you are trying to do?
cannot understand why you have problem to add some number after the name.......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You cant store the same file, into the same folder path, more than once in KM.
KM has the concept of RID(Resource ID), which is defined by the file path. For example if you store a file named File1.txt under say documents folder, then the RID of the file will be /documents/File1.txt. And since RID should be unique, It will not allow you to store any other file (or the same file) with the same name into the same folder path.
Alternate solution will be to append the file name with the current system time stamp or different index every time you upload the file.
Regards,
Vishweshwara P.K.M.
Hi,
You can use the below snippet to append time stamp.
int positonOfDot = fileName.lastIndexOf(".");
String fileExtn = "";
String fileName_withoutExtn = "";
String timestamp = "";
Date currentDate = new Date();
SimpleDateFormat sysTimeStamp = new SimpleDateFormat("yyyyMMddHHmmss");
timestamp = sysTimeStamp.format(currentDate);
if(-1 != positonOfDot){
fileExtn = fileName.substring(positonOfDot + 1);
fileName_withoutExtn = fileName.substring(0, positonOfDot);
fileName = fileName_withoutExtn + "_" + timestamp + "." + fileExtn;
}
Where fileName is the String variable holding the name of the file.
Regards,
Vishweshwara P.K.M.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.