Class FileBody

java.lang.Object
cloud.opencode.base.web.body.FileBody
All Implemented Interfaces:
RequestBody

public final class FileBody extends Object implements RequestBody
File Body - File Request Body 文件请求体 - 文件请求体

Features | 主要功能:

  • File-based HTTP request body - 基于文件的 HTTP 请求体
  • Automatic content type detection - 自动检测内容类型
  • Support for common file extensions - 支持常见文件扩展名
  • Lazy body publisher creation - 延迟创建 body publisher

Usage Examples | 使用示例:

// Auto-detect content type
FileBody body = FileBody.of(Path.of("document.pdf"));

// Explicit content type
FileBody body = FileBody.of(Path.of("data.bin"), "application/octet-stream");

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
  • Null-safe: No (file path must not be null) - 空值安全: 否(文件路径不能为 null)
Since:
JDK 25, opencode-base-web V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: