Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other Open Source Projects and the fly likes Is there any other alternate to find file size and restrict it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Is there any other alternate to find file size and restrict it?" Watch "Is there any other alternate to find file size and restrict it?" New topic
Author

Is there any other alternate to find file size and restrict it?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Hi everybody, I am Chaitanya, I am working on a web application, on of the requirement is to upload files to the server. Say a mp3 song. The user has to upload only files less than or equal to 5MB. I can't do this at the client side. This is done at server side using a servlet.

If the user tries to upload a file say 500MB, the request takes so much time. The entire file must be sent to server, then the servlet must check the file size and take a decision.

But in gmail we have a good approach, the page will not be redirected, but the file will be uploaded, I think its AJAX, I don't know exactly.

But here I see a small problem in gmail. Suppose I have selected the files to be uploaded, then while I am writing the mail, what if the power has cut? So the files will be on the server for no use. How to handle such things?

Thank you all in advance. Have a nice day.


Love all, trust a few, do wrong to none.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Firstly, have you looked at Apache's file upload library? Maintaining state during a large file transfer is certainly non-trivial, if you were to roll your own you'd have to store state on the client and/or server to determine how far through a file you were, not many HTTP based file uploaders do this.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
wood burning stoves
 
subject: Is there any other alternate to find file size and restrict it?
 
Similar Threads
Programmatically simulate user activity on server side to prolongate the HttpSession
Commons FileUpload
Checking file size before uploading
java.lang.IllegalStateException: getOutputStream() error
Max upload file size?