Im trying to use the streaming API for file upload.
I have taken the code sample from the site's "Stream API" section and already have the basic steps.
I need the file to be uploaded available as a byte.
I need code sample for 1. converting an InputStream into byte if anyone has already done that. 2. before using this streaming API I used to get the fileSize by a metod called item.size() Which is the corresponding method in the streaming API?
For #2: I looked in the documentation a bit, then I decided it wasn't really up to me to find out what you meant by that. It would be easier if you just posted the name of the class you were asking about.
ServletFileUpload has a couple of max size settings. They arent exactly what you are asking for, but have you tried using them?
Joined: Jun 18, 2001
Thank you for your reply. Yes, Im using the method for some other size validations.
I did some testing and research in past 3/4 days and may be I have arrived at what is actually happening.
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?
Regards, Leena [ April 09, 2007: Message edited by: Leena Diwan ]