Top Description Fields Constructors Methods
org.apache.hc.client5.http.entity.mime

public Class FileBody

extends AbstractContentBody
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, .OutputStream, org.apache.hc.core5.http.ContentType, org.apache.hc.core5.util.Args

Binary body part backed by a file.
Since
4.0
See Also
org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder

Field Summary

Modifier and TypeField and Description
private final File
private final String

Constructor Summary

AccessConstructor and Description
public
FileBody(final File file)

public
FileBody(final File file, final ContentType contentType, final String filename)

public
FileBody(final File file, final ContentType contentType)

Method Summary

Modifier and TypeMethod and Description
public long
getContentLength()

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Returns the body descriptors content-length.
public File
public String
public InputStream
public void
Inherited from org.apache.hc.client5.http.entity.mime.AbstractContentBody:
getCharsetgetContentTypegetMediaTypegetMimeTypegetSubType

Field Detail

fileback to summary
private final File file
filenameback to summary
private final String filename

Constructor Detail

FileBodyback to summary
public FileBody(final File file)
FileBodyback to summary
public FileBody(final File file, final ContentType contentType, final String filename)
Since
4.3
FileBodyback to summary
public FileBody(final File file, final ContentType contentType)
Since
4.3

Method Detail

getContentLengthback to summary
public long getContentLength()

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Doc from org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Returns the body descriptors content-length.

Returns:long

Content length, if known, or -1, to indicate the absence of a content-length header.

Annotations
@Override
getFileback to summary
public File getFile()
getFilenameback to summary
public String getFilename()

Implements org.apache.hc.client5.http.entity.mime.ContentBody.getFilename.

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream() throws IOException
writeToback to summary
public void writeTo(final OutputStream out) throws IOException

Implements org.apache.hc.client5.http.entity.mime.ContentBody.writeTo.

Annotations
@Override