This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Using getInputStream and file upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using getInputStream and file upload" Watch "Using getInputStream and file upload" New topic
Author

Using getInputStream and file upload

Tom Triolo
Greenhorn

Joined: Oct 06, 2002
Posts: 15
I am uploading a zip file to my server. I use getInputStream to read, while I write to an output stream (either FileOutputStream, or RandomAccessFile "rw"). This is done in a loop.
When I view my uploaded zip file on the server, it tells me there was "206 extra bytes at beginning or within zipfile." This makes my zipfile unable to get processed with another class's method. I get a ZipExeption. I tried setting my content type as both ("text/html") and not setting it at all (not sure why I did that). Any help would be greatly appreciated.
Thanks,
Tom
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
I have to ask why you are trying to re-invent the wheel here. Orielly has an amazing upload package that handles all this in 1 or 2 lines of code!
You can find it here:
http://www.servlets.com/cos/index.html
Tom Triolo
Greenhorn

Joined: Oct 06, 2002
Posts: 15
I like the wheel round like it is, so I will not try to re-invent it. I'll check that out. It would sure save a lot of frustration. Thanks for the reply.
Tom
parag Chatterjee
Greenhorn

Joined: Aug 02, 2002
Posts: 28
I think you should use setContentType("multipart/form-data")
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using getInputStream and file upload
 
Similar Threads
Problem with recognizing file type
OutOfMemoryError using getInputStream()
OutOfMemoryError extracting from ZIP file
OutOfMemoryError when accessing Zip File
problem with opening zip file and reading the contents in the zip files