Java Code Examples for org.springframework.util.MimeTypeUtils#APPLICATION_OCTET_STREAM
The following examples show how to use
org.springframework.util.MimeTypeUtils#APPLICATION_OCTET_STREAM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaClassMimeTypeUtils.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
/** * Convert payload to {@link MimeType} based on the content type on the message. * @param payload the payload to convert * @param originalContentType content type on the message * @return converted {@link MimeType} */ public static MimeType mimeTypeFromObject(Object payload, String originalContentType) { Assert.notNull(payload, "payload object cannot be null."); if (payload instanceof byte[]) { return MimeTypeUtils.APPLICATION_OCTET_STREAM; } if (payload instanceof String) { return MimeTypeUtils.APPLICATION_JSON_VALUE.equals(originalContentType) ? MimeTypeUtils.APPLICATION_JSON : MimeTypeUtils.TEXT_PLAIN; } String className = payload.getClass().getName(); MimeType mimeType = mimeTypesCache.get(className); if (mimeType == null) { String modifiedClassName = className; if (payload.getClass().isArray()) { // Need to remove trailing ';' for an object array, e.g. // "[Ljava.lang.String;" or multi-dimensional // "[[[Ljava.lang.String;" if (modifiedClassName.endsWith(";")) { modifiedClassName = modifiedClassName.substring(0, modifiedClassName.length() - 1); } // Wrap in quotes to handle the illegal '[' character modifiedClassName = "\"" + modifiedClassName + "\""; } mimeType = MimeType .valueOf("application/x-java-object;type=" + modifiedClassName); mimeTypesCache.put(className, mimeType); } return mimeType; }
Example 2
Source File: ByteArrayMessageConverter.java From spring-analysis-note with MIT License | 4 votes |
public ByteArrayMessageConverter() { super(MimeTypeUtils.APPLICATION_OCTET_STREAM); }
Example 3
Source File: ResourceRegionEncoder.java From spring-analysis-note with MIT License | 4 votes |
public ResourceRegionEncoder(int bufferSize) { super(MimeTypeUtils.APPLICATION_OCTET_STREAM, MimeTypeUtils.ALL); Assert.isTrue(bufferSize > 0, "'bufferSize' must be larger than 0"); this.bufferSize = bufferSize; }
Example 4
Source File: ResourceEncoder.java From spring-analysis-note with MIT License | 4 votes |
public ResourceEncoder(int bufferSize) { super(MimeTypeUtils.APPLICATION_OCTET_STREAM, MimeTypeUtils.ALL); Assert.isTrue(bufferSize > 0, "'bufferSize' must be larger than 0"); this.bufferSize = bufferSize; }
Example 5
Source File: ByteArrayMessageConverter.java From java-technology-stack with MIT License | 4 votes |
public ByteArrayMessageConverter() { super(MimeTypeUtils.APPLICATION_OCTET_STREAM); }
Example 6
Source File: ResourceRegionEncoder.java From java-technology-stack with MIT License | 4 votes |
public ResourceRegionEncoder(int bufferSize) { super(MimeTypeUtils.APPLICATION_OCTET_STREAM, MimeTypeUtils.ALL); Assert.isTrue(bufferSize > 0, "'bufferSize' must be larger than 0"); this.bufferSize = bufferSize; }
Example 7
Source File: ResourceEncoder.java From java-technology-stack with MIT License | 4 votes |
public ResourceEncoder(int bufferSize) { super(MimeTypeUtils.APPLICATION_OCTET_STREAM, MimeTypeUtils.ALL); Assert.isTrue(bufferSize > 0, "'bufferSize' must be larger than 0"); this.bufferSize = bufferSize; }
Example 8
Source File: ByteArrayMessageConverter.java From spring4-understanding with Apache License 2.0 | 4 votes |
public ByteArrayMessageConverter() { super(MimeTypeUtils.APPLICATION_OCTET_STREAM); }
Example 9
Source File: PayloadMethodArgumentResolver.java From spring-analysis-note with MIT License | 3 votes |
/** * Decode the content of the given message payload through a compatible * {@link Decoder}. * * <p>Validation is applied if the method argument is annotated with * {@code @javax.validation.Valid} or * {@link org.springframework.validation.annotation.Validated}. Validation * failure results in an {@link MethodArgumentNotValidException}. * * @param parameter the target method argument that we are decoding to * @param message the message from which the content was extracted * @return a Mono with the result of argument resolution * * @see #extractContent(MethodParameter, Message) * @see #getMimeType(Message) */ @Override public final Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) { Payload ann = parameter.getParameterAnnotation(Payload.class); if (ann != null && StringUtils.hasText(ann.expression())) { throw new IllegalStateException("@Payload SpEL expressions not supported by this resolver"); } MimeType mimeType = getMimeType(message); mimeType = mimeType != null ? mimeType : MimeTypeUtils.APPLICATION_OCTET_STREAM; Flux<DataBuffer> content = extractContent(parameter, message); return decodeContent(parameter, message, ann == null || ann.required(), content, mimeType); }