• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
chaitanya karthikk
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.
 
Maneesh Godbole
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.
 
Dave Tolls
Ranch Hand
Posts: 2281
24
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!