WriteOptions class
Options for write operations.
Controls encryption behavior, content type, and custom metadata.
Encryption control
The encrypt field gives callers explicit per-write control:
true: always encrypt. Fails if no encryptor is configured.false: always plaintext, even when encryption is configured.null(default): defer to theEncryptedBackend.encryptByDefaultdecorator's policy, which in turn comes fromCellarEncryption.encryptByDefaultpassed to theCellarconstructor.
Examples
// Encrypt explicitly (fails if encryption not configured):
backend.write(key, bytes, WriteOptions(encrypt: true));
// Plaintext, regardless of default:
backend.write(key, bytes, const WriteOptions.plaintext());
// Defer to the configured default:
backend.write(key, bytes);
Constructors
-
WriteOptions({bool? encrypt, Object? encryptionKey, String? contentType, Map<
String, String> metadata = const {}, void onProgress(int bytesWritten, int? totalBytes)?}) -
Defaults: defer encryption to the backend policy, no content type,
no metadata, no progress reporting.
const
-
WriteOptions.encrypted({String? contentType, Map<
String, String> metadata = const {}, void onProgress(int bytesWritten, int? totalBytes)?}) -
Write encrypted — explicitly request encryption with resolved key.
const
-
WriteOptions.plaintext({String? contentType, Map<
String, String> metadata = const {}, void onProgress(int bytesWritten, int? totalBytes)?}) -
Write as plaintext — explicitly no encryption.
const
Properties
- contentType → String?
-
Content type (MIME type, e.g. "image/png", "audio/mpeg").
final
- encrypt → bool?
-
Whether to encrypt this object.
final
- encryptionKey → Object?
-
Explicit per-call encryption key.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
metadata
→ Map<
String, String> -
Custom metadata to store alongside the file.
final
- onProgress → void Function(int bytesWritten, int? totalBytes)?
-
Optional progress callback for streaming writes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited