getObject function

Future<Uint8List> getObject(
  1. String path
)

Downloads the object at path.

Two round trips: the download needs a buffer sized before it starts, and only the metadata knows how big the object is. Driving both from here keeps the native side from starting one SDK operation inside another's callback.

Implementation

Future<Uint8List> getObject(String path) async {
  final meta = await objectMetadata(path);
  final p = path.toNativeUtf8();
  try {
    return await _awaitBuffer(
      (port) => fdbStorageGet(p.cast(), meta.sizeBytes, port),
      'get $path',
    );
  } finally {
    calloc.free(p);
  }
}