类 URLSource
This source references media files accessible via URLs, supporting both remote HTTP/HTTPS URLs and local file URLs. This approach is preferred when media files are hosted externally or when file size makes Base64 encoding impractical.
Supported URL formats:
- Remote URLs: https://example.com/image.jpg
- Local files: file:///absolute/path/to/file.jpg
Using URL sources is more efficient for large media files and allows the system to stream content rather than loading everything into memory.
When the URL has no file extension (e.g. CDN signed URLs), set mimeType
explicitly so converters can route the content to the correct media slot without
relying on extension-based inference.
-
嵌套类概要
嵌套类 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static URLSource.Builderbuilder()Creates a new builder for constructing URLSource instances.Gets the optional MIME type hint for this URL source.getUrl()Gets the URL that points to the media content.
-
构造器详细资料
-
URLSource
Creates a new URL source for JSON deserialization.- 参数:
url- The URL pointing to the media contentmimeType- Optional MIME type hint (e.g. "image/jpeg"); may be null- 抛出:
NullPointerException- if url is null
-
URLSource
Creates a new URL source without a MIME type hint.- 参数:
url- The URL pointing to the media content- 抛出:
NullPointerException- if url is null
-
-
方法详细资料
-
getUrl
Gets the URL that points to the media content.- 返回:
- The URL as a string
-
getMimeType
Gets the optional MIME type hint for this URL source.When present, converters use this value instead of inferring the type from the URL's file extension. Useful for extension-less URLs such as CDN signed links or API-generated media endpoints.
- 返回:
- The MIME type (e.g. "image/jpeg"), or null if not set
-
builder
Creates a new builder for constructing URLSource instances.- 返回:
- A new builder instance
-