private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); }
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 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); } }
final boolean hasFileName = getFileName(headers) != null; if (hasFileName){ return false; final boolean hasFieldName = getFieldName(headers) != null; if (!hasFieldName){ return false; final String contentType = getContentType(headers); final boolean isMultipartFormData = context.getContentType().startsWith(MULTIPART_FORM_DATA); if (!isMultipartFormData){
static byte[] getDelimiterPrefix(final String contentType){ byte[] boundary = getBoundary(contentType); if (boundary == null || boundary.length == 0){ throw new IllegalStateException("Invalid boundary in the content type " + contentType); } byte[] delimiterPrefix = new byte[boundary.length + 4]; delimiterPrefix[0] = CR; delimiterPrefix[1] = LF; delimiterPrefix[2] = DASH; delimiterPrefix[3] = DASH; System.arraycopy(boundary, 0, delimiterPrefix, 4, boundary.length); return delimiterPrefix; }
protected int getThreshold(final Map<String, List<String>> partHeaders) { final long contentLength = MultipartUtils.getContentLength(partHeaders); return (contentLength > maxSizeThreshold) ? 0 : maxSizeThreshold; }
final boolean hasFileName = getFileName(headers) != null; if (hasFileName){ return false; final boolean hasFieldName = getFieldName(headers) != null; if (!hasFieldName){ return false; final String contentType = getContentType(headers); final boolean isMultipartFormData = context.getContentType().startsWith(MULTIPART_FORM_DATA); if (!isMultipartFormData){
static byte[] getDelimiterPrefix(final String contentType){ byte[] boundary = getBoundary(contentType); if (boundary == null || boundary.length == 0){ throw new IllegalStateException("Invalid boundary in the content type " + contentType); } byte[] delimiterPrefix = new byte[boundary.length + 4]; delimiterPrefix[0] = CR; delimiterPrefix[1] = LF; delimiterPrefix[2] = DASH; delimiterPrefix[3] = DASH; System.arraycopy(boundary, 0, delimiterPrefix, 4, boundary.length); return delimiterPrefix; }
protected int getThreshold(final Map<String, List<String>> partHeaders) { final long contentLength = MultipartUtils.getContentLength(partHeaders); return (contentLength > maxSizeThreshold) ? 0 : maxSizeThreshold; }
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); } }
private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); }
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 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); } }
private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); } }
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 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); } }
private Charset getCharset() { String name = MultipartUtils.getCharEncoding(headers()); return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8); }
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; }
/** * <p> Reads the form fields into a string. The method takes care of handling the char encoding. * <p> If an error occurs while reading the {@link StreamStorage}, an {@link IllegalStateException} will be thrown. * * @param streamStorage The stream storage. * @param headers The part headers. * @return The form parameter value as string. */ public static String readFormParameterValue(final StreamStorage streamStorage, final Map<String, List<String>> headers){ try { return IOUtils.inputStreamAsString(streamStorage.getInputStream(), MultipartUtils.getCharEncoding(headers)); }catch (Exception e){ throw new IllegalStateException("Unable to read the form parameter value", e); } }
/** * <p> Reads the form fields into a string. The method takes care of handling the char encoding. * <p> If an error occurs while reading the {@link StreamStorage}, an {@link IllegalStateException} will be thrown. * * @param streamStorage The stream storage. * @param headers The part headers. * @return The form parameter value as string. */ public static String readFormParameterValue(final StreamStorage streamStorage, final Map<String, List<String>> headers){ try { return IOUtils.inputStreamAsString(streamStorage.getInputStream(), MultipartUtils.getCharEncoding(headers)); }catch (Exception e){ throw new IllegalStateException("Unable to read the form parameter value", e); } }