public <T> T getAttachmentObject(String contentId, Class<T> cls) { Attachment att = getAttachment(contentId); if (att != null) { return att.getObject(cls); } return null; } }
Attachment imageAtt = body.getAttachment("image");
Attachment att = body.getAttachment("appLogo"); if (att != null) { InputStream logoStream = att.getObject(InputStream.class);
public <T> T getAttachmentObject(String contentId, Class<T> cls) { Attachment att = getAttachment(contentId); if (att != null) { return att.getObject(cls); } return null; } }
Attachment att = body.getAttachment("appLogo"); if (att != null) { InputStream logoStream = att.getObject(InputStream.class);
private String getStringValue( MultipartBody multipartBody, String attachmentId ) throws IOException { Attachment attachment = multipartBody.getAttachment( attachmentId ); return attachment == null ? "" : IOUtils.toString( attachment.getDataHandler().getInputStream() ); }
private String getStringValue( MultipartBody multipartBody, String attachmentId ) throws IOException { Attachment attachment = multipartBody.getAttachment( attachmentId ); return attachment == null ? "" : IOUtils.toString( attachment.getDataHandler().getInputStream(), "UTF-8" ); }
/** * Uploads a file encoded in a multipart/form message. * * @param multipart * the multiPart object containing the file to be uploaded * @return a URI with the (custom) uploaded:// scheme and a unique * identifier to be used future ingests. Returns 202 if request succeeds */ @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response upload(MultipartBody multipart){ Attachment file = multipart.getAttachment("file"); if (file == null) { return Response.status(400).entity("Missing file part").type(MediaType.TEXT_PLAIN).build(); } InputStream fileStream = file.getObject(InputStream.class); String uploaded; try { uploaded = m_management.putTempStream(getContext(), fileStream); logger.debug("File uploaded: ", uploaded); } catch (ServerException e) { logger.error(e.toString()); return handleException(e, false); } return Response.status(Response.Status.ACCEPTED).entity(uploaded).type( MediaType.TEXT_PLAIN).build(); } }
/** * Uploads a file encoded in a multipart/form message. * * @param multipart * the multiPart object containing the file to be uploaded * @return a URI with the (custom) uploaded:// scheme and a unique * identifier to be used future ingests. Returns 202 if request succeeds */ @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response upload(MultipartBody multipart){ Attachment file = multipart.getAttachment("file"); if (file == null) { return Response.status(400).entity("Missing file part").type(MediaType.TEXT_PLAIN).build(); } InputStream fileStream = file.getObject(InputStream.class); String uploaded; try { uploaded = m_management.putTempStream(getContext(), fileStream); logger.debug("File uploaded: ", uploaded); } catch (ServerException e) { logger.error(e.toString()); return handleException(e, false); } return Response.status(Response.Status.ACCEPTED).entity(uploaded).type( MediaType.TEXT_PLAIN).build(); } }
Attachment file = multipartBody.getAttachment( "files[]" );
Attachment file = multipartBody.getAttachment( "files[]" );