|
Apache OpenDALâ„¢ C Binding
The C binding for Apache OpenDALâ„¢
|
Options for write operations. More...
#include <opendal.h>
Public Attributes | |
| bool | append |
| const char * | cache_control |
| const char * | content_type |
| const char * | content_disposition |
| const char * | content_encoding |
| const char * | if_match |
| const char * | if_none_match |
| bool | if_not_exists |
| uintptr_t | concurrent |
| bool | has_chunk |
| uintptr_t | chunk |
| const struct opendal_write_user_metadata_pair * | user_metadata |
| uintptr_t | user_metadata_len |
Options for write operations.
Each condition checks the file currently stored at the write path, and the service evaluates it atomically with the write's visible commit:
See the conditional operation specification for the complete cross-operation contract.
Use opendal_write_options_new() to construct and opendal_write_options_free() to free.
A caller that declares the struct itself must initialize every member, for example with opendal_write_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.
| bool opendal_write_options::append |
Sets append mode for this operation.
Check opendal_capability.write_can_append before using this option.
This operation allows adding data to existing files instead of overwriting them.
| const char* opendal_write_options::cache_control |
Sets Cache-Control header for this write operation.
Check opendal_capability.write_with_cache_control before using this feature.
This operation allows controlling caching behavior for the written content.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_cache_control() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| uintptr_t opendal_write_options::chunk |
Sets chunk size for buffered writes.
Check opendal_capability.write_multi_min_size and opendal_capability.write_multi_max_size for size limits.
Setting appropriate chunk size can:
has_chunk controls whether this value applies.
| uintptr_t opendal_write_options::concurrent |
Sets concurrent write operations for this writer.
opendal_operator_write_with() without chunk passes the whole buffer to the service writer as one write. A service that splits the buffer internally, such as fs with direct_io on Linux, can write the parts concurrently.
This feature significantly improves performance when:
Setting appropriate concurrency can:
0 is the default.
| const char* opendal_write_options::content_disposition |
Sets Content-Disposition header for this write request.
Check opendal_capability.write_with_content_disposition before using this feature.
This operation allows controlling how the content should be displayed or downloaded.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_content_disposition() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_write_options::content_encoding |
Sets Content-Encoding header for this write request.
Check opendal_capability.write_with_content_encoding before using this feature.
This operation allows specifying the encoding applied to the content being written.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_content_encoding() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_write_options::content_type |
Sets Content-Type header for this write operation.
Check opendal_capability.write_with_content_type before using this feature.
This operation allows specifying the media type of the content being written.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_content_type() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| bool opendal_write_options::has_chunk |
Whether chunk has been set.
| const char* opendal_write_options::if_match |
Write only when the file at the write path has this exact ETag.
The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag, or a missing file, fails the write with OPENDAL_CONDITION_NOT_MATCH. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_match.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_if_match() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_write_options::if_none_match |
Write only when the file at the write path does not have this ETag.
With a concrete ETag value, the condition succeeds when the file has a different ETag or does not exist; the write then replaces or creates the file. A file whose ETag equals this value fails the write with OPENDAL_CONDITION_NOT_MATCH. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_none_match. Some services, such as s3, support if_not_exists but not if_none_match; use if_not_exists when you only need to guard against an existing file.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_write_options_set_if_none_match() stores this pointer without copying the string, and opendal_write_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| bool opendal_write_options::if_not_exists |
Write only when no file exists at the write path.
The condition succeeds when the path is empty, so the write creates the file. An existing file fails the write with OPENDAL_CONDITION_NOT_MATCH.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_not_exists.
| const struct opendal_write_user_metadata_pair* opendal_write_options::user_metadata |
Sets user metadata for this write request.
Check opendal_capability.write_with_user_metadata before using this feature.
User metadata provides a way to attach custom metadata to objects during write operations. When the service exposes user metadata, opendal_metadata_get_user_metadata() on the result of a later opendal_operator_stat() returns it.
NULL or a user_metadata_len of 0 means unset. opendal_write_options_set_user_metadata() stores this pointer without copying the pairs or their strings, and opendal_write_options_free() does not free them, so they must stay valid until the function that takes these options returns. A pair whose key or value is NULL is skipped, and a later pair replaces an earlier pair with the same key.
| uintptr_t opendal_write_options::user_metadata_len |
The number of pairs at user_metadata.