Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload in IE / Struts

 
Chandrakant Nambiar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chandrakant Nambiar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chandrakant Nambiar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies for any inconvenience caused to ranchers for the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic