LCOV - code coverage report
Current view: top level - src - multipart_file_io.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 12 83.3 %
Date: 2020-02-27 17:47:50 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : import 'dart:io';
       3             : import 'package:http_parser/http_parser.dart';
       4             : import 'package:path/path.dart' as p;
       5             : import 'multipart_file.dart';
       6             : 
       7           1 : Future<MultipartFile> multipartFileFromPath(
       8             :   String filePath, {
       9             :   String filename,
      10             :   MediaType contentType,
      11             : }) async {
      12           0 :   filename ??= p.basename(filePath);
      13           1 :   var file = File(filePath);
      14           2 :   var length = await file.length();
      15           1 :   var stream = file.openRead();
      16           1 :   return MultipartFile(
      17             :     stream,
      18             :     length,
      19             :     filename: filename,
      20             :     contentType: contentType,
      21             :   );
      22             : }
      23             : 
      24           1 : MultipartFile multipartFileFromPathSync(
      25             :   String filePath, {
      26             :   String filename,
      27             :   MediaType contentType,
      28             : }) {
      29           0 :   filename ??= p.basename(filePath);
      30           1 :   var file = File(filePath);
      31           1 :   var length = file.lengthSync();
      32           1 :   var stream = file.openRead();
      33           1 :   return MultipartFile(
      34             :     stream,
      35             :     length,
      36             :     filename: filename,
      37             :     contentType: contentType,
      38             :   );
      39             : }

Generated by: LCOV version 1.14