posted 14 years ago
Hi,
I'm using the Apache FileUpload lib to deal with file uploads. It generally works fine however Ive come across an annoying bug.
A user can upload a zip file, the code that obtains the ref to the stream is this:
It goes on to deal with the stream. I read the bytes from itemStream, checking the total number of bytes I've read each time. If the total number of bytes read exceeds a MAX_FILE_SIZE limit I throw an exception and deal with it.
This is the issue:
When I call itemStream.close() the code seems to wait at this point while the browser continues to upload the file, when the upload is done the itemStream.close() returns and the code carries on.
What I would have expected is itemStream.close() to terminate the stream's connection immediately, I know the file size is already too big, so I don't want to waste time/bandwidth waiting for the rest of it to upload before I can display an appropriate message to the user.
Imagine for some reason the user tries to upload a 50Gb file, when the limit is 10Mb, they'd have to wait until 50Gb were streamed before the error response was displayed to the user!!
Any ideas how to abort a file upload??