updateMetadata method

  1. @override
Future<void> updateMetadata(
  1. String key, {
  2. String? contentType,
  3. Map<String, String> metadata = const {},
})
override

Update metadata for an existing object without touching its bytes.

Used after streaming writes where some metadata field (e.g. the original-plaintext size for an encrypted file) is only known once the stream completes.

  • Local: rewrites the .meta.json sidecar.
  • IndexedDB: re-reads the record and writes it back with the updated metadata fields.
  • A remote store: copy-to-itself with new metadata (when it has no in-place metadata update).

Implementation

@override
Future<void> updateMetadata(
  String key, {
  String? contentType,
  Map<String, String> metadata = const {},
}) async {
  checkNotDisposed();
  final manifest = await _readManifest(key);
  if (manifest == null) throw FileNotFoundError(key);
  await _writeManifest(
    key,
    generation: manifest.generation,
    chunkCount: manifest.chunkCount,
    totalSize: manifest.totalSize,
    contentType: contentType,
    metadata: metadata,
  );
}