Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to validate a file extension and discard the http request if the extension is not supported  RSS feed

 
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a webservice class which actually handles multipart requests. T client will try to upload zip or tar.gz files which may be upto 1GB in size.

I dont want to validate the extension i client side.

I want to validate the file extension in server side and discard the request before the file is uploaded.

How can I do this?

Thanks all in advance.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you wish to validate the file extension(s) of the file being uploaded (tar.gz/zip) or the file extension(s) of the file(s) inside the compressed file being uploaded?
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Do you wish to validate the file extension(s) of the file being uploaded (tar.gz/zip) or the file extension(s) of the file(s) inside the compressed file being uploaded?

I wish to validate the extension of the file being uploaded.
 
Master Rancher
Posts: 4087
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chaitanya karthikk wrote:

Maneesh Godbole wrote:Do you wish to validate the file extension(s) of the file being uploaded (tar.gz/zip) or the file extension(s) of the file(s) inside the compressed file being uploaded?

I wish to validate the extension of the file being uploaded.



The exact method depends on the upload code you're using, but you should have access to the original file name.
For example, an Apache FileUpload FileItem has a getName for getting the filename.
 
Poop goes in a willow feeder. Wipe with this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!