This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using com.oreilly.servlet for upload to different directories

 
James Gordon
Ranch Hand
Posts: 106
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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 ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic