ClonableMultipartFile.fromFileSync constructor

ClonableMultipartFile.fromFileSync(
  1. String filePath
)

Creates a new ClonableMultipartFile from a file specified by the filePath.

Implementation

factory ClonableMultipartFile.fromFileSync(String filePath) {
  final file = File(filePath);
  final length = file.lengthSync();
  final stream = file.openRead();
  var name = file.path.split('/').last;

  return ClonableMultipartFile(
    filePath,
    'file',
    stream,
    length,
    filename: name,
  );
}