File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes File Upload in IE / Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File Upload in IE / Struts" Watch "File Upload in IE / Struts" New topic
Author

File Upload in IE / Struts

Chandrakant Nambiar
Greenhorn

Joined: Aug 10, 2006
Posts: 13
Hi Guys,

Can anyone here kindly let me know the maximum size of a file that could be uploaded through IE using Struts? I have a requirement to upload text files of more than 100MB in Java. Is this possible? Is the maximum size configurable? Any help/links for the same would be appreciated.

Thanks,
Chandrakant
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Neither the Struts upload feature nor IE impose any upper limits on what size file can be uploaded. You can impose such a limit in your code, however.

For examples, the best place to go is the sample code that comes with the Struts download. You will find sample code there that does a file upload with an imposed size limit. If you're using Struts 1.3.5, the name of the sample application file is struts-examples-1.3.5.war.


Merrill
Consultant, Sima Solutions
Chandrakant Nambiar
Greenhorn

Joined: Aug 10, 2006
Posts: 13
Thanks for the quick reply.
But i have not imposed any restriction anywhere in the code. Does it mean that i can even upload text files of size more than 200MB (thats my requirement) in my Struts/IE application? My code works perfect for file sizes upto 40MB. After that it fails to deliver. Any idea what could be wrong. Thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd spend some time looking at the sample code. I'd also try deploying the sample code and using it to upload a large file. That will give you some indication as to whether there is something wrong with your code.

One other point: If you try to read the whole file into memory, then the size of the file you can upload will be limited by the amount of memory allocated to the JVM. Make sure you're adopting a strategy of reading a portion of the input stream, and the writing to the output stream immmediately and then getting the next portion of the input stream.
[ March 05, 2007: Message edited by: Merrill Higginson ]
Chandrakant Nambiar
Greenhorn

Joined: Aug 10, 2006
Posts: 13
Thanks once again, Merrill.
FYI, the code that i am using to write the file is:

BufferedOutputStream outStream =
new BufferedOutputStream(new FileOutputStream(savedFile),
40048);
int count;
byte[] databuff = new byte[40048];

while ((count = inStream.read(databuff, 0, 40048)) != -1) {
outStream.write(databuff, 0, count);
}

outStream.flush();
outStream.close();
inStream.close();

Any suggestions to improve this? Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60991
    
  65

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.

I have closed all your other posts in this matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chandrakant Nambiar
Greenhorn

Joined: Aug 10, 2006
Posts: 13
My apologies for any inconvenience caused to ranchers for the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload in IE / Struts