@Override protected ParserToken computeNext() { byte[] buffer = new byte[1024]; int read; try { ParserToken next; next = parserTokens.poll(); if (next != null && next.getType() == null){ return endOfData(); } if (next != null){ return next; } while (null == (next = parserTokens.poll()) && -1 != (read = inputStream.read(buffer))) { parser.write(buffer, 0, read); } if (next != null && next.getType() == null){ return endOfData(); } if (next != null){ return next; } throw new IllegalStateException("Error parsing the multipart stream. Stream ended unexpectedly"); }catch (Exception e){ throw new IllegalStateException("Error parsing the multipart stream", e); } }
@Override protected ParserToken computeNext() { byte[] buffer = new byte[1024]; int read; try { ParserToken next; next = parserTokens.poll(); if (next != null && next.getType() == null){ return endOfData(); } if (next != null){ return next; } while (null == (next = parserTokens.poll()) && -1 != (read = inputStream.read(buffer))) { parser.write(buffer, 0, read); } if (next != null && next.getType() == null){ return endOfData(); } if (next != null){ return next; } throw new IllegalStateException("Error parsing the multipart stream. Stream ended unexpectedly"); }catch (Exception e){ throw new IllegalStateException("Error parsing the multipart stream", e); } }
/** * <p> * Parses the multipart stream and it return the parts in form of {@link Iterable}. * </p> * * @param inputStream The multipart stream * @param multipartContext The multipart context * @param partBodyStreamStorageFactory The {@code PartBodyStreamStorageFactory} to use * @param bufferSize The buffer size in bytes * @param maxHeadersSectionSize The max size of the headers section in bytes * @param maxLevelOfNestedMultipart the max number of nested multipart * @return the parts in the form of a closeable iterator */ @SuppressWarnings("unchecked") public static CloseableIterator<ParserToken> parse(final InputStream inputStream, final MultipartContext multipartContext, final PartBodyStreamStorageFactory partBodyStreamStorageFactory, final int bufferSize, final int maxHeadersSectionSize, final int maxLevelOfNestedMultipart) { return new PartItemsIterator(inputStream, multipartContext, partBodyStreamStorageFactory, bufferSize, maxHeadersSectionSize, maxLevelOfNestedMultipart); }
/** * <p> * Parses the multipart stream and it return the parts in form of {@link Iterable}. * </p> * * @param inputStream The multipart stream * @param multipartContext The multipart context * @param partBodyStreamStorageFactory The {@code PartBodyStreamStorageFactory} to use * @param bufferSize The buffer size in bytes * @param maxHeadersSectionSize The max size of the headers section in bytes * @param maxLevelOfNestedMultipart the max number of nested multipart * @return the parts in the form of a closeable iterator */ @SuppressWarnings("unchecked") public static CloseableIterator<ParserToken> parse(final InputStream inputStream, final MultipartContext multipartContext, final PartBodyStreamStorageFactory partBodyStreamStorageFactory, final int bufferSize, final int maxHeadersSectionSize, final int maxLevelOfNestedMultipart) { return new PartItemsIterator(inputStream, multipartContext, partBodyStreamStorageFactory, bufferSize, maxHeadersSectionSize, maxLevelOfNestedMultipart); }