Class FileAttachment
java.lang.Object
cloud.opencode.base.email.attachment.FileAttachment
- All Implemented Interfaces:
Attachment
File-based Email Attachment
基于文件的邮件附件
Attachment implementation for local file system files.
本地文件系统文件的附件实现。
Features | 主要功能:
- Load from Path - 从Path加载
- Auto-detect MIME type - 自动检测MIME类型
- Lazy loading - 延迟加载
Usage Examples | 使用示例:
Attachment attachment = new FileAttachment(Path.of("report.pdf"));
Email email = Email.builder()
.attach(attachment)
.build();
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Immutable: Yes - 不可变: 是
- Since:
- JDK 25, opencode-base-email V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFileAttachment(Path path) Create file attachment from path 从路径创建文件附件FileAttachment(Path path, String fileName) Create file attachment with custom file name 创建带自定义文件名的文件附件FileAttachment(Path path, String fileName, String contentType) Create file attachment with custom file name and content type 创建带自定义文件名和内容类型的文件附件 -
Method Summary
Modifier and TypeMethodDescriptionGet attachment MIME type 获取附件MIME类型Get attachment file name 获取附件文件名Get attachment data as input stream 获取附件数据输入流getPath()Get the file path 获取文件路径longgetSize()Get attachment size in bytes 获取附件大小(字节)static FileAttachmentCreate file attachment from path string 从路径字符串创建文件附件static FileAttachmentCreate file attachment from path 从路径创建文件附件toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Attachment
getContentId, isInline
-
Constructor Details
-
FileAttachment
Create file attachment from path 从路径创建文件附件- Parameters:
path- the file path | 文件路径
-
FileAttachment
-
FileAttachment
-
-
Method Details
-
of
Create file attachment from path 从路径创建文件附件- Parameters:
path- the file path | 文件路径- Returns:
- the file attachment | 文件附件
-
of
Create file attachment from path string 从路径字符串创建文件附件- Parameters:
path- the file path string | 文件路径字符串- Returns:
- the file attachment | 文件附件
-
getFileName
Description copied from interface:AttachmentGet attachment file name 获取附件文件名- Specified by:
getFileNamein interfaceAttachment- Returns:
- the file name | 文件名
-
getContentType
Description copied from interface:AttachmentGet attachment MIME type 获取附件MIME类型- Specified by:
getContentTypein interfaceAttachment- Returns:
- the MIME type | MIME类型
-
getInputStream
Description copied from interface:AttachmentGet attachment data as input stream 获取附件数据输入流- Specified by:
getInputStreamin interfaceAttachment- Returns:
- the input stream | 输入流
-
getSize
public long getSize()Description copied from interface:AttachmentGet attachment size in bytes 获取附件大小(字节)- Specified by:
getSizein interfaceAttachment- Returns:
- the size in bytes | 字节大小
-
getPath
-
toString
-