move method

Future<String> move({
  1. required String toPath,
  2. required String name,
})

Move the file into a local path on disk. Creates directories as needed.

Implementation

Future<String> move({
  required String toPath,
  required String name,
}) async {
  final fullPath = sanitizeRoutePath('$toPath/$name');
  final file = File(fullPath);
  await file.parent.create(recursive: true);
  final sink = file.openWrite();
  await for (final chunk in stream) {
    sink.add(chunk);
  }
  await sink.close();

  // strip leading /public if used
  return fullPath.replaceFirst(RegExp(r'^/?public'), '');
}