public class FileDownload extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
FileDownload.Builder
Allows creating a
FileDownload with
the specified FileDownload.Mode . |
static class |
FileDownload.Mode
Download mode.
|
Constructor and Description |
---|
FileDownload(FileDownload.Mode mode,
byte[] content,
String fileName)
Creates a new file attachment.
|
FileDownload(FileDownload.Mode mode,
InputStream content,
String fileName)
Creates a new file attachment.
|
FileDownload(FileDownload.Mode mode,
InputStream content,
String fileName,
long fileSize)
Creates a new file attachment.
|
FileDownload(FileDownload.Mode mode,
Path file)
Creates a new file attachment.
|
FileDownload(FileDownload.Mode mode,
Path file,
String fileName)
Creates a new file attachment.
|
Modifier and Type | Method and Description |
---|---|
static FileDownload.Builder |
build(byte[] content,
String fileName)
Creates a builder with the specified content which can be used to create
a
FileDownload with any FileDownload.Mode . |
static FileDownload.Builder |
build(InputStream content,
String fileName)
Creates a builder with the specified content which can be used to create
a
FileDownload with any FileDownload.Mode . |
static FileDownload.Builder |
build(InputStream content,
String fileName,
long fileSize)
Creates a builder with the specified content which can be used to create
a
FileDownload with any FileDownload.Mode . |
static FileDownload.Builder |
build(Path file)
Creates a builder with the specified content which can be used to create
a
FileDownload with any FileDownload.Mode . |
static FileDownload.Builder |
build(Path file,
String fileName)
Creates a builder with the specified content which can be used to create
a
FileDownload with any FileDownload.Mode . |
String |
getContentDisposition()
Content disposition header.
|
MediaType |
getContentType()
File content type.
|
String |
getFileName()
File name.
|
long |
getFileSize()
File size or
-1 if unknown. |
InputStream |
stream()
File content.
|
String |
toString() |
public FileDownload(FileDownload.Mode mode, @Nonnull InputStream content, @Nonnull String fileName, long fileSize)
mode
- Download mode.content
- File content.fileName
- Filename.fileSize
- File size or -1
if unknown.public FileDownload(FileDownload.Mode mode, @Nonnull InputStream content, @Nonnull String fileName)
mode
- Download mode.content
- File content.fileName
- Filename.public FileDownload(FileDownload.Mode mode, @Nonnull byte[] content, @Nonnull String fileName)
mode
- Download mode.content
- File content.fileName
- Filename.public FileDownload(FileDownload.Mode mode, @Nonnull Path file, @Nonnull String fileName) throws IOException
mode
- Download mode.file
- File content.fileName
- Filename.IOException
- For IO exception while reading file.public FileDownload(FileDownload.Mode mode, @Nonnull Path file) throws IOException
mode
- Download mode.file
- File content.IOException
- For IO exception while reading file.public long getFileSize()
-1
if unknown.-1
if unknown.public MediaType getContentType()
public String getFileName()
public String getContentDisposition()
public InputStream stream()
public static FileDownload.Builder build(@Nonnull InputStream content, @Nonnull String fileName, long fileSize)
FileDownload
with any FileDownload.Mode
.content
- File content.fileName
- Filename.fileSize
- File size or -1
if unknown.FileDownload.Builder
with the specified contentpublic static FileDownload.Builder build(@Nonnull InputStream content, @Nonnull String fileName)
FileDownload
with any FileDownload.Mode
.content
- File content.fileName
- Filename.FileDownload.Builder
with the specified contentpublic static FileDownload.Builder build(@Nonnull byte[] content, @Nonnull String fileName)
FileDownload
with any FileDownload.Mode
.content
- File content.fileName
- Filename.FileDownload.Builder
with the specified contentpublic static FileDownload.Builder build(@Nonnull Path file, @Nonnull String fileName)
FileDownload
with any FileDownload.Mode
.file
- File content.fileName
- Filename.FileDownload.Builder
with the specified contentpublic static FileDownload.Builder build(@Nonnull Path file)
FileDownload
with any FileDownload.Mode
.file
- File content.FileDownload.Builder
with the specified contentCopyright © 2022. All rights reserved.