Solved

Get file size before upload begins

Posted on 2007-04-09
5
2,898 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now