I want to add something here in this discussion. Some days back, I have faced the 
problem , that file will be overwritten if both of them have same name. As a matter of 
fact, in my application the need is bit different. The web application permits the 
user to upload the file which is to be  finally stored as BLOB in oracle database. So 
if I can directly get the handle to the output stream of Filepart, it could be easier 
for me rather than storing it in temp location then reading it and storing as BLOB and 
then delete the temp file.

But I found the using filepart.getInputStream() doesn't give the stream , as the 
servlet input stream is getting closed. So as work around, I'm currently planning to 
generate file names with file name+time stamp+random no. for storing in temp location 
as well as I have changed the class  so that it can multipart request can give me the 
actual name as a well as the name in which it's stored, so that I can retrieve the 
file and move the content as BLOB with actual name.


Do u have any other solution ? Then pls let me know.

Thanks,
Sudarson


-----Original Message-----
From: Jason Hunter [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 6:42 AM
To: [EMAIL PROTECTED]
Subject: Re: Sevlet Upload Question


Is it really a deficiency in the com.oreilly.servlet code?

The COS library provides MultipartParser to do all the heavy lifting
parsing work.  As a convenience there's the MultipartRequest
fairly-trivial front end that takes a directory in its constructor and
saves the uploaded files there.  If you want some other front end,
providing things like overwrite handling or saving different files to
another location, you can write another front end basing on the MR
code.  I see that's what you did; you wrote a front end to read the
files into memory and avoid the filesystem.

But to be honest, I'm going to need to be convinced it's necessary.
I've let MR write the files to a temp directory and then let the web app
move them to the appropriate "golden" location.  The web app can enforce
the business logic on how it want to deal with conflicts (like newer
file wins or original file wins or file gets renamed or whatever).  That
also saves you from ever having partial uploads in the "golden"
location.  A file move on the same filesystem is an extremely fast
operation compared to the upload, so no slowdown.  It also solves the
problem where you need to change the location based on a parameter,
since there's no guarantee the parameter will come before the files in
the upload stream.

I could provide a class that had built-in handling for overwrites, but
is there an agreed-upon way?  Old wins, new wins, or rename?  And if
rename, how shall we rename?

-jh-

Jeff Schnitzer wrote:
>
> This is actually a very serious deficiency in the O'Reilly code, and
> pretty much makes it unusable for anything other than a toy website.
> Basically, if two people simultaneously upload files with the same name,
> horrible things happen.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to