MultipartFileRecreatable.fromFileSync constructor

MultipartFileRecreatable.fromFileSync(
  1. String filePath, {
  2. String? filename,
  3. MediaType? contentType,
  4. Map<String, List<String>>? headers,
})

Creates a MultipartFileRecreatable object from a File in filePath.

Implementation

factory MultipartFileRecreatable.fromFileSync(
  String filePath, {
  String? filename,
  MediaType? contentType,
  Map<String, List<String>>? headers,
}) {
  filename ??= p.basename(filePath);
  final file = File(filePath);
  final length = file.lengthSync();
  final stream = file.openRead();
  return MultipartFileRecreatable(
    stream,
    length,
    filename: filename,
    contentType: contentType,
    headers: headers,
  );
}