public class FormDataFile extends Object
Constructor and Description |
---|
FormDataFile(String fileName,
ContentType contentType,
Path localPath,
long size)
Create a FormDataFile.
|
Instance Methods | |
---|---|
String |
fileName()
The name of the file, as reported by the client.
|
ContentType |
contentType()
The content type of the file, as reported by the client.
|
Path |
localPath()
Where the file is stored on the local file system.
|
long |
size()
The size of the file.
|
String |
toString()
A string representing this object, for diagnosis purpose.
|
void |
delete()
Delete the local file identified by
localPath . |
Static Method | |
FormDataFile |
of(String localPath)
Create a FormDataFile based on the local file.
|
public FormDataFile(String fileName, ContentType contentType, Path localPath, long size)
public static FormDataFile of(String localPath)
The ContentType is looked up from FileSuffixToContentType.getGlobalInstance()
.
CAUTION: this method reads file metadata from OS, which may involve blocking IO operations.
RuntimeException
- if the file does not existpublic String fileName()
The file name may contain chars that are invalid on the server's file system.
public ContentType contentType()
This method may return null.
public Path localPath()
FormParser
will store the file on local file system,
and this path identifies where it is stored.
This path does not necessarily contain fileName()
.
public long size()
public String toString()
public void delete()
localPath
.
This method is non-blocking; errors will be silently logged.