MultipartInputStream multipartStream = new MultipartInputStream(requestInputStream, sSeparator.getBytes(sEncoding),
sEncoding);
while (multipartStream.nextPart())
{
MIMEHeader header = multipartStream.getHeaders().find("Content-Disposition");
if (header == null)
{
continue;
}
MIMEHeader.Value value = header.getFirstValue();
if (value == null || !value.getName().equals("form-data") && !value.getName().equals("attachment"))
{
continue;
}
String sName = value.findArg("name");
if (sName == null)
{
continue;
}
String sFileName = getFilenameForUpload(header);
header = multipartStream.getHeaders().find("Content-Type");
if (header != null && header.getFirstValue() != null && header.getFirstValue().getName().startsWith("multipart/"))
{
throw new MultipartDataException("Multiple files per input are not supported");
}
long lMaxSize = lDefMaxSize;