• 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

Struts2: How to do file upload validation programatically ?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please let me know how to do the file upload validation programatically instead of interceptors ?

I want to allow file type of xls only, Min size and max size

Thanks,
Sakthi Priya
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you want to do a file upload in Struts 2 and not use the Struts 2 file upload mechanism?

Edit

Oh, I think I misunderstood what you were asking; missed the part about validation.

If the commons-upload/regular file upload validation doesn't work for you why not just validate in a validate() method? The "validation" interceptor is in the stack after file upload, so you can do whatever you need to.
 
Sakthi Priya
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please throw some highlight about validate() method? Do i need to implement any interfaces ?

Right now what i'm doing is, on uploading i'm calling some action mthod. Within that method, using the value of
getUploadContentType() i'm deciding whether to throw back the error or not. Still not sure about restricting minimum and maximum size allowed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic