putFile method

Future<PutResponse> putFile(
  1. File file,
  2. String token, {
  3. PutOptions? options,
})

Implementation

Future<PutResponse> putFile(
  File file,
  String token, {
  PutOptions? options,
}) async {
  options ??= PutOptions();
  RequestTask<PutResponse> task;
  final useSingle = options.forceBySingle == true ||
      file.lengthSync() < (options.partSize * 1024 * 1024);
  final resource = FileResource(
    file: file,
    length: await file.length(),
    name: options.key,
    partSize: useSingle ? null : options.partSize,
  );

  if (useSingle) {
    task = PutBySingleTask(
      resource: resource,
      options: options,
      token: token,
      filename: basename(file.path),
    );
  } else {
    task = PutByPartTask(
      token: token,
      options: options,
      resource: resource,
    );
  }

  taskManager.addTask(task);

  return task.future;
}