dumpBuffer method

Future<Map<String, dynamic>> dumpBuffer(
  1. Uint8List writeBuffer
)

Implementation

Future<Map<String, dynamic>> dumpBuffer(Uint8List writeBuffer) async {
  if (writeBuffer.isEmpty) {
    // Chunk is empty, may be last chunk
    return <String, dynamic>{};
  }

  var chunk = <String, dynamic>{
    'files_id': id,
    'n': currentChunkNumber,
    'data': BsonBinary.from(writeBuffer)
  };
  currentChunkNumber++;

  totalBytes += writeBuffer.length;
  /*  var actualLength = contentToDigest.length;
  var contentTemp = Uint8List(totalBytes);
  contentTemp.setAll(0, contentToDigest);
  contentTemp.setAll(actualLength, writeBuffer);
  contentToDigest = contentTemp; */

  return fs.chunks.insert(chunk);
}