/** * Gets the field value for this body part. This should be called only on body parts representing simple field values. * * @return the simple field value. * @throws ProcessingException if an IO error arises during reading the value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain} */ public String getValue() { if (!MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } if (getEntity() instanceof BodyPartEntity) { return getValueAs(String.class); } else { return (String) getEntity(); } }
mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
@POST @Path("/coverpic") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile(FormDataMultiPart multiPart){ FormDataBodyPart body = multiPart.getField(<your fieldname>); InputStream ins = ((BodyPartEntity) body.getEntity()).getInputStream(); ///..... ///..... return Response.status(200).entity(output).build(); }
mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
/** * Gets the field value for this body part. This should be called only on body parts representing simple field values. * * @return the simple field value. * @throws ProcessingException if an IO error arises during reading the value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain} */ public String getValue() { if (!MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } if (getEntity() instanceof BodyPartEntity) { return getValueAs(String.class); } else { return (String) getEntity(); } }
mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
/** * Gets the field value for this body part. This should be called only on body parts representing simple field values. * * @return the simple field value. * @throws ProcessingException if an IO error arises during reading the value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain} */ public String getValue() { if (!MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } if (getEntity() instanceof BodyPartEntity) { return getValueAs(String.class); } else { return (String) getEntity(); } }
mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
/** * Gets the field value for this body part. This should be called only on body parts representing simple field values. * * @return the simple field value. * @throws ProcessingException if an IO error arises during reading the value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain} */ public String getValue() { if (!MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } if (getEntity() instanceof BodyPartEntity) { return getValueAs(String.class); } else { return (String) getEntity(); } }
/** * Gets the field value for this body part. This should be called only on body parts representing simple field values. * * @return the simple field value. * @throws ProcessingException if an IO error arises during reading the value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain} */ public String getValue() { if (!MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } if (getEntity() instanceof BodyPartEntity) { return getValueAs(String.class); } else { return (String) getEntity(); } }
BodyPartEntity bodyPart = (BodyPartEntity) filePart.getEntity();