java.lang.Object
io.jooby.FileDownload
- Direct Known Subclasses:
AttachedFile
,InlineFile
Represents a file download.
- Since:
- 2.9.0
- Author:
- edgar, imeszaros
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Allows creating aFileDownload
with the specifiedFileDownload.Mode
.static enum
Download mode. -
Constructor Summary
ConstructorDescriptionFileDownload
(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileDownload.Builder
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.static FileDownload.Builder
build
(InputStream content, String fileName) Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.static FileDownload.Builder
build
(InputStream content, String fileName, long fileSize) Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.static FileDownload.Builder
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.static FileDownload.Builder
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.Content disposition header.File content type.File name.long
File size or-1
if unknown.stream()
File content.toString()
-
Constructor Details
-
FileDownload
public FileDownload(FileDownload.Mode mode, @NonNull InputStream content, @NonNull String fileName, long fileSize) Creates a new file attachment.- Parameters:
mode
- Download mode.content
- File content.fileName
- Filename.fileSize
- File size or-1
if unknown.
-
FileDownload
Creates a new file attachment.- Parameters:
mode
- Download mode.content
- File content.fileName
- Filename.
-
FileDownload
Creates a new file attachment.- Parameters:
mode
- Download mode.content
- File content.fileName
- Filename.
-
FileDownload
public FileDownload(FileDownload.Mode mode, @NonNull Path file, @NonNull String fileName) throws IOException Creates a new file attachment.- Parameters:
mode
- Download mode.file
- File content.fileName
- Filename.- Throws:
IOException
- For IO exception while reading file.
-
FileDownload
Creates a new file attachment.- Parameters:
mode
- Download mode.file
- File content.- Throws:
IOException
- For IO exception while reading file.
-
-
Method Details
-
getFileSize
public long getFileSize()File size or-1
if unknown.- Returns:
- File size or
-1
if unknown.
-
getContentType
File content type.- Returns:
- File content type.
-
getFileName
File name.- Returns:
- File name.
-
getContentDisposition
Content disposition header.- Returns:
- Content disposition header.
-
stream
File content.- Returns:
- File content.
-
toString
-
build
public static FileDownload.Builder build(@NonNull InputStream content, @NonNull String fileName, long fileSize) Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.- Parameters:
content
- File content.fileName
- Filename.fileSize
- File size or-1
if unknown.- Returns:
- a
FileDownload.Builder
with the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.- Parameters:
content
- File content.fileName
- Filename.- Returns:
- a
FileDownload.Builder
with the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.- Parameters:
content
- File content.fileName
- Filename.- Returns:
- a
FileDownload.Builder
with the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.- Parameters:
file
- File content.fileName
- Filename.- Returns:
- a
FileDownload.Builder
with the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownload
with anyFileDownload.Mode
.- Parameters:
file
- File content.- Returns:
- a
FileDownload.Builder
with the specified content
-