Solved

Get file size before upload begins

Posted on 2007-04-09
5
2,914 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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?
Many of the companies I’ve worked with have embraced cloud solutions due to their desire to “get out of the datacenter business.” The ability to achieve better security and availability, and the speed with which they are able to deploy, is far grea…
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…
Six Sigma Control Plans

627 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