Module Operator.Writer

Writer Operations

Module for writing data to files in chunks.

val write : Opendal_core.Operator.writer -> bytes -> (unit, string) Stdlib.result

write writer data writes a chunk of data.

  • parameter writer

    The writer instance

  • parameter data

    Data chunk to write

Example:

match Writer.write writer (Bytes.of_string "Hello ") with
| Ok () -> (
    match Writer.write writer (Bytes.of_string "World!") with
    | Ok () -> print_endline "Data written"
    | Error err -> printf "Error: %s\n" err)
| Error err -> printf "Error: %s\n" err
val close : Opendal_core.Operator.writer -> (Opendal_core.Operator.metadata, string) Stdlib.result

close writer finalizes the write operation and returns metadata.

Must be called to ensure all data is properly written and committed.

  • parameter writer

    The writer instance

  • returns

    Metadata about the written file

Example:

(* After writing all chunks *)
match Writer.close writer with
| Ok metadata ->
    printf "File closed successfully, size: %Ld bytes\n"
      (Metadata.content_length metadata)
| Error err -> printf "Error closing file: %s\n" err