public class FileHttpEntity extends Object implements HttpEntity
The body of the entity is the content of the file.
This is a sharable entity.
Constructor and Description |
---|
FileHttpEntity(Path filePath,
ContentType contentType)
Create an FileHttpEntity over the file specified by `filePath`.
|
Instance Methods | |
---|---|
ByteSource |
body()
The body of the entity, same as the content of the file.
|
ContentType |
contentType()
The content type.
|
Long |
contentLength()
Return the size of the file.
|
Instant |
lastModified()
Return the last modified time of the file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bodyBytes, bodyString, contentEncoding, etag, etagIsWeak, expires
public FileHttpEntity(Path filePath, ContentType contentType) throws Exception
If contentType==null, we'll use
FileSuffixToContentType.getGlobalInstance()
to get the content type from the file suffix.
CAUTION: this constructor reads file metadata from OS, which may involve blocking IO operations.
Exception
public ByteSource body()
body
in interface HttpEntity
public ContentType contentType()
contentType
in interface HttpEntity
public Long contentLength()
contentLength
in interface HttpEntity
public Instant lastModified()
lastModified
in interface HttpEntity