struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lee Clemens" <j...@leeclemens.net>
Subject RE: Unique Id creation
Date Wed, 16 Dec 2009 04:39:57 GMT
OP: What Struts tag are you using to upload multiple files at the same time?
I may be wrong, but I didn't know this was possible with Struts.   If so,
what filename are they given by default? I use file upload tags but they are
saved as default-named files I can access via the File setter in my Action
(file.getAbsolutePath()).

Otherwise, I would suggest going with a solution along the line of PK's
solution with UUID (probably best with the ms timestamp) as part of the file
name or using SecureRandom.nextInt and Integer.MAX_VALUE.

To be extra safe, you could have a static Set to maintain all file names and
ensure it not is contained in that Set before creating it (and populate the
Set during initialization).


TG, Out of curiosity, why would the current milliseconds past epoch need to
be zero-padded? (besides code written for ~277 years from now, when it still
likely wouldn't matter?)

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com] 
Sent: Tuesday, December 15, 2009 3:02 PM
To: Struts Users Mailing List
Subject: Re: Unique Id creation

jayakumar ala wrote:
> Hi All,
>  I am using struts2 in my web application.
>  Which is the best way to create unique Id for each file upload i do in my
> application...?
>
> Thanks
> Ala
>
>   

I've always used the original filename with a time stamp, down to the 
millisecond formatted with leading zeros and without separators, 
appended to the end.  If a create fails, I wait a few milliseconds and 
regenerate the filename.  The nice part about the time stamp is that you 
have the date and time the file was uploaded in the name itself.

TG

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message