body = factory.binaryBody(decodedStream);
body = factory.binaryBody(decodedStream);
public BinaryBody buildBinary() throws IOException { Charset cs = this.charset != null ? this.charset : Charsets.DEFAULT_CHARSET; if (this.bodyFactory != null) { if (this.text != null) { return this.bodyFactory.binaryBody(InputStreams.create(this.text, cs)); } else if (this.bin != null) { return this.bodyFactory.binaryBody(InputStreams.create(this.bin)); } else { return this.bodyFactory.binaryBody((InputStreams.create(new byte[]{}))); } } else { if (this.bin != null) { return BasicBodyFactory.INSTANCE.binaryBody(this.bin); } else if (this.text != null) { return BasicBodyFactory.INSTANCE.binaryBody(this.text, cs); } else { return BasicBodyFactory.INSTANCE.binaryBody(new byte [] {}); } } }
public void body(BodyDescriptor bd, final InputStream is) throws MimeException, IOException { expect(Entity.class); final Body body; if (bd.getMimeType().startsWith("text/")) { body = bodyFactory.textBody(is, bd.getCharset()); } else { body = bodyFactory.binaryBody(is); } Entity entity = ((Entity) stack.peek()); entity.setBody(body); }
body = factory.binaryBody(decodedStream);
/** * Sets binary content of this message with the given MIME type. * * @param body * the body. * @param mimeType * the MIME media type of the specified body * ("type/subtype"). */ public BodyPartBuilder setBody(byte[] bin, String mimeType) throws IOException { setField(Fields.contentType(mimeType != null ? mimeType : "application/octet-stream")); Body binBody; if (bodyFactory != null) { binBody = bodyFactory.binaryBody(InputStreams.create(bin)); } else { binBody = BasicBodyFactory.INSTANCE.binaryBody(bin); } return setBody(binBody); }
/** * Sets binary content of this message with the given MIME type. * * @param bin * the body. * @param mimeType * the MIME media type of the specified body * ("type/subtype"). */ public Builder setBody(byte[] bin, String mimeType) throws IOException { setField(Fields.contentType(mimeType != null ? mimeType : "application/octet-stream")); Body binBody; if (bodyFactory != null) { binBody = bodyFactory.binaryBody(InputStreams.create(bin)); } else { binBody = BasicBodyFactory.INSTANCE.binaryBody(bin); } return setBody(binBody); }
public MultipartBuilder addBinaryPart(byte[] bin, String mimeType) throws IOException { BinaryBody body = bodyFactory != null ? bodyFactory.binaryBody(InputStreams.create(bin)) : BasicBodyFactory.INSTANCE.binaryBody(bin); BodyPart bodyPart = BodyPartBuilder.create() .setBody(body) .setContentType(mimeType != null ? mimeType : "application/octet-stream") .setContentTransferEncoding("base64") .build(); return addBodyPart(bodyPart); }