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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAllows creating aFileDownloadwith the specifiedFileDownload.Mode.static enumDownload mode. -
Constructor Summary
ConstructorsConstructorDescriptionFileDownload(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.BuilderCreates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.static FileDownload.Builderbuild(InputStream content, String fileName) Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.static FileDownload.Builderbuild(InputStream content, String fileName, long fileSize) Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.static FileDownload.BuilderCreates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.static FileDownload.BuilderCreates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.Content disposition header.File content type.File name.longFile size or-1if 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-1if 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-1if unknown.- Returns:
- File size or
-1if 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 aFileDownloadwith anyFileDownload.Mode.- Parameters:
content- File content.fileName- Filename.fileSize- File size or-1if unknown.- Returns:
- a
FileDownload.Builderwith the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.- Parameters:
content- File content.fileName- Filename.- Returns:
- a
FileDownload.Builderwith the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.- Parameters:
content- File content.fileName- Filename.- Returns:
- a
FileDownload.Builderwith the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.- Parameters:
file- File content.fileName- Filename.- Returns:
- a
FileDownload.Builderwith the specified content
-
build
Creates a builder with the specified content which can be used to create aFileDownloadwith anyFileDownload.Mode.- Parameters:
file- File content.- Returns:
- a
FileDownload.Builderwith the specified content
-