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

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

Issue 12382003: Revert "Change MultipartFile.fromFile to MultipartFile.fromPath in pkg/http." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | pkg/http/pubspec.yaml » ('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 07443b80385f4d38ee147e177a9da1470b9f9a12..50f47047117f9a0164299a4b8a8dd103a24f17b4 100644
--- a/pkg/http/lib/src/multipart_file.dart
+++ b/pkg/http/lib/src/multipart_file.dart
@@ -7,8 +7,6 @@ library multipart_file;
import 'dart:async';
import 'dart:io';
-import 'package:pathos/path.dart' as path;
-
import 'byte_stream.dart';
import 'utils.dart';
@@ -80,15 +78,14 @@ class MultipartFile {
}
// TODO(nweiz): Infer the content-type from the filename.
- /// Creates a new [MultipartFile] from a path to a file on disk.
+ /// Creates a new [MultipartFile] from a [File].
///
- /// [filename] defaults to the basename of [filePath]. [contentType] currently
- /// defaults to `application/octet-stream`, but in the future may be inferred
- /// from [filename].
- static Future<MultipartFile> fromPath(String field, String filePath,
+ /// [filename] defaults to the name of the file on disk. [contentType]
+ /// currently defaults to `application/octet-stream`, but in the future may be
+ /// inferred from [filename].
+ static Future<MultipartFile> fromFile(String field, File file,
{String filename, ContentType contentType}) {
- if (filename == null) filename = path.basename(filePath);
- var file = new File(filePath);
+ if (filename == null) filename = new Path(file.name).filename;
return file.length().then((length) {
var stream = new ByteStream(file.openRead());
return new MultipartFile(field, stream, length,
« no previous file with comments | « no previous file | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698