Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1500)

Unified Diff: lib/src/multipart_file.dart

Issue 1922883004: Fix more strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/http.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/multipart_file.dart
diff --git a/lib/src/multipart_file.dart b/lib/src/multipart_file.dart
index f15b6848eddac09f4ee871b887c7b95dcbd8d9b7..3597c6ef598acf9be4e2778ee4815f0395c296a2 100644
--- a/lib/src/multipart_file.dart
+++ b/lib/src/multipart_file.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
+import 'package:async/async.dart';
import 'package:http_parser/http_parser.dart';
import 'package:path/path.dart' as path;
@@ -86,16 +87,15 @@ class MultipartFile {
///
/// This can only be used in an environment that supports "dart:io".
static Future<MultipartFile> fromPath(String field, String filePath,
- {String filename, MediaType contentType}) {
+ {String filename, MediaType contentType}) async {
io.assertSupported("MultipartFile.fromPath");
if (filename == null) filename = path.basename(filePath);
var file = io.newFile(filePath);
- return file.length().then((length) {
- var stream = new ByteStream(file.openRead());
- return new MultipartFile(field, stream, length,
- filename: filename,
- contentType: contentType);
- });
+ var length = await file.length();
+ var stream = new ByteStream(DelegatingStream.typed(file.openRead()));
+ return new MultipartFile(field, stream, length,
+ filename: filename,
+ contentType: contentType);
}
// Finalizes the file in preparation for it being sent as part of a
« no previous file with comments | « lib/http.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698