Page
Library
Module
Module type
Parameter
Class
Class type
Source
Jsonfeed.AttachmentSourceAttachments for JSON Feed items.
An attachment represents an external resource related to a feed item, such as audio files for podcasts, video files, or other downloadable content. Attachments with identical titles indicate alternate formats of the same resource.
The type representing an attachment.
Declarative JSON type for attachments.
Maps JSON objects with "url" (required), "mime_type" (required), and optional "title", "size_in_bytes", "duration_in_seconds" fields.
val create :
url:string ->
mime_type:string ->
?title:string ->
?size_in_bytes:int64 ->
?duration_in_seconds:int ->
?unknown:Unknown.t ->
unit ->
tcreate ~url ~mime_type ?title ?size_in_bytes ?duration_in_seconds ?unknown () creates an attachment object.
Examples:
(* Simple attachment *)
let att =
Attachment.create ~url:"https://example.com/episode.mp3"
~mime_type:"audio/mpeg" ()
(* Podcast episode with metadata *)
let att =
Attachment.create ~url:"https://example.com/episode.mp3"
~mime_type:"audio/mpeg" ~title:"Episode 42" ~size_in_bytes:15_728_640L
~duration_in_seconds:1800 ()size_in_bytes t returns the attachment's size in bytes, if set.
duration_in_seconds t returns the attachment's duration, if set.
pp ppf t pretty prints an attachment to the formatter.
The output is human-readable and suitable for debugging.
Example output:
episode.mp3 (audio/mpeg, 15.0 MB, 30m0s)