All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.ipokerface.weixin.request.http.apache.ByteArrayBody Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package cn.ipokerface.weixin.request.http.apache;

import cn.ipokerface.weixin.request.http.ContentType;

import java.io.IOException;
import java.io.OutputStream;

/**
 * Created by       PokerFace
 * Create Date      2019-12-27.
 * Email:           [email protected]
 * Version          1.0.0
 * 

* Description: */ public class ByteArrayBody extends AbstractContentBody { /** * The contents of the file contained in this part. */ private final byte[] data; /** * The name of the file contained in this part. */ private final String filename; /** * Creates a new ByteArrayBody. * * @param data The contents of the file contained in this part. * @param mimeType The MIME type of the file contained in this part. * @param filename The name of the file contained in this part. * */ public ByteArrayBody(final byte[] data, final String mimeType, final String filename) { this(data, ContentType.create(mimeType), filename); } /** * @since 4.3 */ public ByteArrayBody(final byte[] data, final ContentType contentType, final String filename) { super(contentType); this.data = data; this.filename = filename; } /** * Creates a new ByteArrayBody. * * @param data The contents of the file contained in this part. * @param filename The name of the file contained in this part. */ public ByteArrayBody(final byte[] data, final String filename) { this(data, "application/octet-stream", filename); } @Override public String getFilename() { return filename; } @Override public void writeTo(final OutputStream out) throws IOException { out.write(data); } @Override public String getCharset() { return null; } @Override public String getTransferEncoding() { return Mime.ENC_BINARY; } @Override public long getContentLength() { return data.length; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy