Solved

Get file size before upload begins

Posted on 2007-04-09
5
2,904 Views
Last Modified: 2013-11-21
Hello Friends,
I want to throw an error immediately if user is trying to upload a file of size greater than the specified limit. We are checking content-Length for this.

If Im not mistaken, for large files the issue is because of the behaviours of HTML and Java: Once the user hits on upload button, the file is included in the request body as the enctype is multipart/form-data. If the connection is slower [this application can be used over internet from user being anywhere in the world] the time taken for a file >10 MBs is considerable.

By the time the whole request is prepared and sent to the server, a lot of time elapses. Then the method you have specified can be called on the fileItem.

If the user is trying to upload a file way above the limit, like of 50MB or 100MB, then the time taken to reach till the point error gets thrown increases.

As of now we are experiencing delays in giving the size limit error message to user like the following- 10MB file ~ 10minutes. 33 MB file ~ 30 minutes and so on.

What can we do for improving this? Or is there any way to get the file size before even the upload begins?

rahulak
0
Comment
Question by:rahulak
5 Comments
 
LVL 11

Accepted Solution

by:
Manish earned 43 total points
ID: 18897001
0
 
LVL 7

Assisted Solution

by:Chandan_Gowda
Chandan_Gowda earned 41 total points
ID: 18936768
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 41 total points
ID: 19041967
most servers start the application (wether in Java or any other language) right *after* it completed to read the hole request.
Hence it's a more or less useless attempt to check the size in the application for performance/bandwidth issues, obviously.
If your server passes the connection to your application right away, then you can read the content-Length header yourself and decide what to do.But keep in mind that ther must not be such a header if the client sends the data using Connection:close. In that case you have to read data 'til your limit.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question