public String getContentType() { return inputPart.getMediaType().toString(); }
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream, final MultipartRelatedInput xopPackage) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); InputPart rootPart = xopPackage.getRootPart(); JAXBContext jaxb = findJAXBContext(type, annotations, rootPart .getMediaType(), true); Unmarshaller unmarshaller = jaxb.createUnmarshaller(); unmarshaller .setAttachmentUnmarshaller(new XopAttachmentUnmarshaller( xopPackage)); return unmarshaller.unmarshal(new StreamSource(rootPart.getBody( InputStream.class, null))); } catch (JAXBException e) { Response response = Response.serverError().build(); throw new WebApplicationException(e, response); } }
public String getContentType() { return inputPart.getMediaType().toString(); }
private String charset(final InputPart part) { return part.getMediaType().getParameters().get("charset"); //$NON-NLS-1$ }
private String charset(final InputPart part) { return part.getMediaType().getParameters().get("charset"); //$NON-NLS-1$ }
private static Map<String, String> getTextFormFields(final String format, final MultipartInput multipartInput, final Set<String> assetNames) throws IOException { Map<String, String> fields = new HashMap<>(); List<InputPart> fieldsParts = multipartInput.getParts().stream() .filter(part -> TEXT_PLAIN_TYPE.isCompatible(part.getMediaType())) .collect(toList()); for (InputPart inputPart : fieldsParts) { Optional<String> maybeContentDisposition = getContentDisposition(inputPart); if (maybeContentDisposition.isPresent()) { Optional<String> maybeFieldName = extractFieldName(format, maybeContentDisposition.get()); if (maybeFieldName.isPresent() && !assetNames.contains(maybeFieldName.get())) { fields.put(maybeFieldName.get(), inputPart.getBodyAsString()); } } } return fields; }
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream, final MultipartRelatedInput xopPackage) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); InputPart rootPart = xopPackage.getRootPart(); JAXBContext jaxb = findJAXBContext(type, annotations, rootPart .getMediaType(), true); Unmarshaller unmarshaller = jaxb.createUnmarshaller(); unmarshaller .setAttachmentUnmarshaller(new XopAttachmentUnmarshaller( xopPackage)); return unmarshaller.unmarshal(new StreamSource(rootPart.getBody( InputStream.class, null))); } catch (JAXBException e) { Response response = Response.serverError().build(); throw new WebApplicationException(e, response); } }
public static Map<String, Object> toMap(MultipartInput input) { Map<String, Object> result = new HashMap<>(); try { for (InputPart p : input.getParts()) { String name = MultipartUtils.extractName(p); if (name == null || name.startsWith("/") || name.contains("..")) { throw new ConcordApplicationException("Invalid attachment name: " + name); } if (name.endsWith(JSON_FIELD_SUFFIX)) { name = name.substring(0, name.length() - JSON_FIELD_SUFFIX.length()); Object v = objectMapper.readValue(p.getBodyAsString(), Object.class); result.put(name, v); } else if (p.getMediaType().isCompatible(MediaType.TEXT_PLAIN_TYPE)) { String currentValue = p.getBodyAsString().trim(); result.compute(name, (k, oldValue) -> computeStringMultipartEntry(oldValue, currentValue)); } else { result.put(name, p.getBody(InputStream.class, null)); } } return result; } catch (IOException e) { throw new ConcordApplicationException("Error parsing the request", e); } }
private static Map<String, InputStreamPartPayload> getAssetsPayloads(final String format, final MultipartInput multipartInput) throws IOException { Map<String, InputStreamPartPayload> payloads = new HashMap<>(); for (InputPart inputPart : multipartInput.getParts()) { Optional<String> maybeContentDisposition = getContentDisposition(inputPart); if (maybeContentDisposition.isPresent()) { String contentDisposition = maybeContentDisposition.get(); Optional<String> maybeFieldName = extractFieldName(format, contentDisposition); if (maybeFieldName.isPresent()) { String fieldName = maybeFieldName.get(); boolean isAsset = fieldName.matches(ASSET_NAME_REGEX); if (isAsset) { Optional<String> maybeFilename = extractFilename(contentDisposition); InputStream inputStream = inputPart.getBody(InputStream.class, null); String filename = maybeFilename.orElse(null); String contentType = inputPart.getMediaType().toString(); InputStreamPartPayload payload = new InputStreamPartPayload(filename, fieldName, inputStream, contentType); payloads.put(fieldName, payload); } } } } return payloads; }
if (p.getMediaType().isCompatible(MediaType.TEXT_PLAIN_TYPE)) { String v = p.getBodyAsString().trim(); Map<String, Object> m = ConfigurationUtils.toNested(name, v);
MediaType mediaType = filePart.getMediaType(); if (!mediaType.getType().equals("image")) {