write method

Future<void> write(
  1. String path,
  2. List<int> bytes, {
  3. bool executable = false,
  4. void onProgress(
    1. int sent,
    2. int total
    )?,
})

Writes bytes to path under the served root.

When executable is true the node marks the written file +x.

When onProgress is supplied it reports the cumulative on-wire bytes sent for this write against the frame total, paced by the channel's send window.

Implementation

Future<void> write(
  String path,
  List<int> bytes, {
  bool executable = false,
  void Function(int sent, int total)? onProgress,
}) {
  final (payload, gz) = DriveCompression.encodePayload(path, bytes);
  return _call(
    DriveOp.write,
    fields: {
      'path': path,
      if (gz) kDriveGzipFlag: true,
      if (executable) kDriveExecutable: true,
    },
    payload: payload,
    onSent: onProgress,
  );
}