This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using com.oreilly.servlet for upload to different directories

 
James Gordon
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My form allow users to upload 2 files, both to a different directories. When we create the MultipartRequest, we need to specific a location. And then, everything would go inside there.
MultipartRequest m =
new MultipartRequest
(request, "e:/loc", 1024 * 1024);
Is there anyway to go around this?

Thanks in advance.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch! Please adjust your display name to meet
the JavaRanch Naming Policy. You can change it here.
Thanks!
and welcome to the JavaRanch!
 
Garann Means
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ehchn1,
Does the "save directory" location have to be the absolute path? Does your code work a location like the one in your example?
Thanks!
g.
 
Sandeep Jain
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well , what I feel here there is no way u can achieve this fuctionality without modifying the MultipartRequest.java file .
So what u can do is inside the constructor of MultipartRequest file u can check for the file type or ur condition on which u want to put ur file in the respective directory and make the call to its other constructor which takes 2 parameters and can set the direcory also .
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upload both files to a temporary holding directory, and just move them after they are uploaded.

There is a related question in the cos faq:
[ August 10, 2002: Message edited by: Mike Curwen ]
 
James Gordon
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for all the feedbacks.
I managed to get in touch with the creater of the package. According to him, I have to use the MultipartParser instead if I want more controls.
Else I have to do like what Mike pointed out, which is dumping the files to a temporary directory first.
But personally, I would say that the 2nd solution is not that feasible because my code would be platform dependent then. Moving the files manually is a waste of effort, thus what I can think of is by using the Runtime class to move the files automatically. To do that, I have to invoke the OS command which is not the same for all platforms.

Thanks.
 
Mario Rendon
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike's Solution is the one i addopted but unfortunatelly if the client press the stop button before the file is uploaded . then in your temp dir there will be some garbage and you have to include a Garbage colection schema ..
Mike have yod had that problem ??
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic