• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using com.oreilly.servlet for upload to different directories

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic