public class DownloadedFile extends FileBase implements Closeable
content, contentSize, contentType, name| Constructor and Description |
|---|
DownloadedFile(File file)
下载文件
|
DownloadedFile(File file,
String name)
下载文件
|
DownloadedFile(File file,
String name,
String contentType)
下载文件
|
DownloadedFile(String contentType,
byte[] content,
String name)
下载文件
|
DownloadedFile(String contentType,
InputStream content,
String name)
下载文件
|
DownloadedFile(String contentType,
long contentSize,
InputStream content,
String name)
下载文件
|
| Modifier and Type | Method and Description |
|---|---|
DownloadedFile |
asAttachment(boolean attachment)
作为附件输出
|
DownloadedFile |
cacheControl(int maxAgeSeconds)
缓存控制
|
void |
close() |
DownloadedFile |
eTag(String eTag)
eTag 配置
|
InputStream |
getContent()
内容
|
long |
getContentSize()
内容大小
|
String |
getETag()
获取 eTag
|
Date |
getLastModified()
获取最后修改时间
|
int |
getMaxAgeSeconds()
获取最大缓存时间(0表示不缓存)
|
boolean |
isAttachment()
是否附件输出
|
DownloadedFile |
lastModified(Date lastModified)
最后更新时间配置(单位:毫秒)
|
getContentType, getNamepublic DownloadedFile(String contentType, long contentSize, InputStream content, String name)
contentType - 内容类型contentSize - 内容大小content - 内容流name - 文件名public DownloadedFile(String contentType, InputStream content, String name)
contentType - 内容类型content - 内容流name - 文件名public DownloadedFile(String contentType, byte[] content, String name)
contentType - 内容类型content - 内容流name - 文件名public DownloadedFile(File file) throws FileNotFoundException
file - 文件FileNotFoundExceptionpublic DownloadedFile(File file, String name) throws FileNotFoundException
file - 文件name - 名字FileNotFoundExceptionpublic DownloadedFile(File file, String name, String contentType) throws FileNotFoundException
file - 文件name - 名字FileNotFoundExceptionpublic boolean isAttachment()
public int getMaxAgeSeconds()
public String getETag()
public Date getLastModified()
public DownloadedFile asAttachment(boolean attachment)
public DownloadedFile cacheControl(int maxAgeSeconds)
public DownloadedFile eTag(String eTag)
public DownloadedFile lastModified(Date lastModified)
public InputStream getContent() throws IOException
IOExceptionpublic long getContentSize()
throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2025. All rights reserved.