AbstractSynchronossPart(HttpHeaders headers, DataBufferFactory bufferFactory) { Assert.notNull(headers, "HttpHeaders is required"); Assert.notNull(bufferFactory, "DataBufferFactory is required"); this.name = MultipartUtils.getFieldName(headers); this.headers = headers; this.bufferFactory = bufferFactory; }
private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); }
private Part createPart(StreamStorage storage, HttpHeaders httpHeaders) { String filename = MultipartUtils.getFileName(httpHeaders); if (filename != null) { return new SynchronossFilePart(httpHeaders, filename, storage, this.bufferFactory); } else if (MultipartUtils.isFormField(httpHeaders, this.context)) { String value = MultipartUtils.readFormParameterValue(storage, httpHeaders); return new SynchronossFormFieldPart(httpHeaders, this.bufferFactory, value); } else { return new SynchronossPart(httpHeaders, storage, this.bufferFactory); } }
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name()); .multipart(context) .usePartBodyStreamStorageFactory(this.streamStorageFactory) .forNIO(listener); buffer.read(resultBytes); try { parser.write(resultBytes); listener.onError("Exception thrown providing input to the parser", ex); listener.onError("Request body input error", ex); parser.close(); listener.onError("Exception thrown while closing the parser", ex2); parser.close(); listener.onError("Exception thrown while closing the parser", ex);
void nestedPartRead(final WriteContext wCtx){ delimiterPrefixes.pop(); delimiterType.reset(); endOfLineBuffer.recycle(getPreambleDelimiterPrefix(delimiterPrefixes.peek()), null); goToState(State.SKIP_PREAMBLE); nioMultipartParserListener.onNestedPartFinished(); wCtx.setFinishedIfNoMoreData(); }
void getReadyForBody(final WriteContext wCtx) { partBodyStreamStorage = partBodyStreamStorageFactory.newStreamStorageForPartBody(headers, partIndex); endOfLineBuffer.recycle(delimiterPrefixes.peek(), partBodyStreamStorage); delimiterType.reset(); goToState(State.READ_BODY); wCtx.setFinishedIfNoMoreData(); }
@Override public void close() throws IOException { parser.close(); } }
void allPartsRead(final WriteContext wCtx) { goToState(State.SKIP_EPILOGUE); nioMultipartParserListener.onAllPartsFinished(); wCtx.setFinishedIfNoMoreData(); }
/** * <p> Creates the {@code CloseableIterator}. Use this to process in a blocking IO manner. * * @param inputStream The {@code InputStream} with the multipart content. * @return The {@code CloseableIterator} */ public CloseableIterator<ParserToken> forBlockingIO(final InputStream inputStream){ return BlockingIOAdapter.parse(inputStream, context, partStreamsFactory(), bufferSize, headersSizeLimit, nestedMultipartsAllowed); } }
/** * <p> Builds a {@code NioMultipartParser}. Use this to process the multipart stream in a non blocking fashion. * * @param listener The {@code NioMultipartParserListener} listener * @return The {@code NioMultipartParser} */ public NioMultipartParser forNIO(final NioMultipartParserListener listener){ return new NioMultipartParser(context, listener, partStreamsFactory(), bufferSize, headersSizeLimit, nestedMultipartsAllowed); }
/** * <p> Checks if the headers contains a Content-Type header that defines a multipart request. * * @param headers The headers map * @return true if the request is a multipart request, false otherwise. */ public static boolean hasMultipartContentType(final Map<String, List<String>> headers){ return isMultipart(getContentType(headers)); }
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name()); .multipart(context) .usePartBodyStreamStorageFactory(this.streamStorageFactory) .forNIO(listener); buffer.read(resultBytes); try { parser.write(resultBytes); listener.onError("Exception thrown providing input to the parser", ex); listener.onError("Request body input error", ex); parser.close(); listener.onError("Exception thrown while closing the parser", ex2); parser.close(); listener.onError("Exception thrown while closing the parser", ex);
private Part createPart(StreamStorage storage, HttpHeaders httpHeaders) { String filename = MultipartUtils.getFileName(httpHeaders); if (filename != null) { return new SynchronossFilePart(httpHeaders, filename, storage, this.bufferFactory); } else if (MultipartUtils.isFormField(httpHeaders, this.context)) { String value = MultipartUtils.readFormParameterValue(storage, httpHeaders); return new SynchronossFormFieldPart(httpHeaders, this.bufferFactory, value); } else { return new SynchronossPart(httpHeaders, storage, this.bufferFactory); } }
void nestedPartRead(final WriteContext wCtx){ delimiterPrefixes.pop(); delimiterType.reset(); endOfLineBuffer.recycle(getPreambleDelimiterPrefix(delimiterPrefixes.peek()), null); goToState(State.SKIP_PREAMBLE); nioMultipartParserListener.onNestedPartFinished(); wCtx.setFinishedIfNoMoreData(); }
AbstractSynchronossPart(HttpHeaders headers, DataBufferFactory bufferFactory) { Assert.notNull(headers, "HttpHeaders is required"); Assert.notNull(bufferFactory, "DataBufferFactory is required"); this.name = MultipartUtils.getFieldName(headers); this.headers = headers; this.bufferFactory = bufferFactory; }
private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); }
void allPartsRead(final WriteContext wCtx) { goToState(State.SKIP_EPILOGUE); nioMultipartParserListener.onAllPartsFinished(); wCtx.setFinishedIfNoMoreData(); }
/** * <p> Creates the {@code CloseableIterator}. Use this to process in a blocking IO manner. * * @param inputStream The {@code InputStream} with the multipart content. * @return The {@code CloseableIterator} */ public CloseableIterator<ParserToken> forBlockingIO(final InputStream inputStream){ return BlockingIOAdapter.parse(inputStream, context, partStreamsFactory(), bufferSize, headersSizeLimit, nestedMultipartsAllowed); } }
/** * <p> Builds a {@code NioMultipartParser}. Use this to process the multipart stream in a non blocking fashion. * * @param listener The {@code NioMultipartParserListener} listener * @return The {@code NioMultipartParser} */ public NioMultipartParser forNIO(final NioMultipartParserListener listener){ return new NioMultipartParser(context, listener, partStreamsFactory(), bufferSize, headersSizeLimit, nestedMultipartsAllowed); }
AbstractSynchronossPart(HttpHeaders headers, DataBufferFactory bufferFactory) { Assert.notNull(headers, "HttpHeaders is required"); Assert.notNull(bufferFactory, "DataBufferFactory is required"); this.name = MultipartUtils.getFieldName(headers); this.headers = headers; this.bufferFactory = bufferFactory; }