类org.apache.http.entity.mime.MIME源码实例Demo

下面列出了怎么用org.apache.http.entity.mime.MIME的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cyberduck   文件: DelayedHttpMultipartEntity.java
/**
 * @param status Length
 */
public DelayedHttpMultipartEntity(final String filename, final TransferStatus status, final String boundary) {
    this.status = status;
    final StringBuilder multipartHeader = new StringBuilder();
    multipartHeader.append(TWO_DASHES);
    multipartHeader.append(boundary);
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("Content-Disposition: form-data; name=\"file\"; filename=\"%s\"", filename));
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("%s: %s", HTTP.CONTENT_TYPE, StringUtils.isBlank(status.getMime()) ? MimeTypeService.DEFAULT_CONTENT_TYPE : status.getMime()));
    multipartHeader.append(CR_LF);
    multipartHeader.append(CR_LF);
    header = encode(MIME.DEFAULT_CHARSET, multipartHeader.toString()).buffer();
    final StringBuilder multipartFooter = new StringBuilder();
    multipartFooter.append(CR_LF);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(boundary);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(CR_LF);
    footer = encode(MIME.DEFAULT_CHARSET, multipartFooter.toString()).buffer();
}
 
源代码2 项目: iaf   文件: HttpSender.java
protected FormBodyPart createMultipartBodypart(String name, String message, String contentType) {
	ContentType cType = ContentType.create("text/plain", getCharSet());
	if(StringUtils.isNotEmpty(contentType))
		cType = ContentType.create(contentType, getCharSet());

	FormBodyPartBuilder bodyPart = FormBodyPartBuilder.create()
		.setName(name)
		.setBody(new StringBody(message, cType));

	if (StringUtils.isNotEmpty(getMtomContentTransferEncoding()))
		bodyPart.setField(MIME.CONTENT_TRANSFER_ENC, getMtomContentTransferEncoding());

	return bodyPart.build();
}
 
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
 
源代码4 项目: iaf   文件: MultipartForm.java
private static void writeBytes(
		final String s, final OutputStream out) throws IOException {
	final ByteArrayBuffer b = encode(MIME.DEFAULT_CHARSET, s);
	writeBytes(b, out);
}
 
源代码5 项目: iaf   文件: MultipartForm.java
/**
 * Creates an instance with the specified settings.
 *
 * @param charset the character set to use. May be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
 * @param boundary to use  - must not be {@code null}
 * @throws IllegalArgumentException if charset is null or boundary is null
 */
public MultipartForm(final Charset charset, final String boundary, final List<FormBodyPart> parts) {
	Args.notNull(boundary, "Multipart boundary");
	this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
	this.boundary = boundary;
	this.parts = parts;
}
 
 类所在包
 同包方法