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

Unified Diff: pkg/http/lib/src/multipart_file.dart

Issue 261763002: Rip out the last dart:io dependency from pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 | « pkg/http/lib/src/io_client.dart ('k') | pkg/http/test/client_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/multipart_file.dart
diff --git a/pkg/http/lib/src/multipart_file.dart b/pkg/http/lib/src/multipart_file.dart
index 220c28633f4cb59b7e63817e3a7fd6d6c614096a..07758b9097fb5713eebfed084c0643c7da3a2b7f 100644
--- a/pkg/http/lib/src/multipart_file.dart
+++ b/pkg/http/lib/src/multipart_file.dart
@@ -5,7 +5,6 @@
library multipart_file;
import 'dart:async';
-import 'dart:io';
import 'dart:convert';
import 'package:http_parser/http_parser.dart';
@@ -13,6 +12,7 @@ import 'package:path/path.dart' as path;
import 'package:stack_trace/stack_trace.dart';
import 'byte_stream.dart';
+import 'io.dart' as io;
import 'utils.dart';
/// A file to be uploaded as part of a [MultipartRequest]. This doesn't need to
@@ -86,10 +86,13 @@ class MultipartFile {
/// [filename] defaults to the basename of [filePath]. [contentType] currently
/// defaults to `application/octet-stream`, but in the future may be inferred
/// from [filename].
+ ///
+ /// This can only be used in an environment that supports "dart:io".
static Future<MultipartFile> fromPath(String field, String filePath,
{String filename, MediaType contentType}) {
+ io.assertSupported("MultipartFile.fromPath");
if (filename == null) filename = path.basename(filePath);
- var file = new File(filePath);
+ var file = io.newFile(filePath);
return Chain.track(file.length()).then((length) {
var stream = new ByteStream(Chain.track(file.openRead()));
return new MultipartFile(field, stream, length,
« no previous file with comments | « pkg/http/lib/src/io_client.dart ('k') | pkg/http/test/client_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698