putBytes method

Future<PutResponse> putBytes(
  1. Uint8List bytes,
  2. String token, {
  3. PutOptions? options,
})

Implementation

Future<PutResponse> putBytes(
  Uint8List bytes,
  String token, {
  PutOptions? options,
}) async {
  options ??= PutOptions();
  RequestTask<PutResponse> task;
  final useSingle = options.forceBySingle == true ||
      bytes.length < (options.partSize * 1024 * 1024);
  final resource = BytesResource(
    bytes: bytes,
    length: bytes.length,
    name: options.key,
    partSize: useSingle ? null : options.partSize,
  );

  if (useSingle) {
    task = PutBySingleTask(
      resource: resource,
      options: options,
      token: token,
      filename: null,
    );
  } else {
    task = PutByPartTask(
      token: token,
      options: options,
      resource: resource,
    );
  }

  taskManager.addTask(task);

  return task.future;
}