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

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

Issue 12388004: Add a change for r19194 that got eaten in a merge. (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 | no next file » | 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 0246c0748c6a27e4eeca54b84abc51638fbaa960..aa30fc350989bd82a6a98f7e92e13ae6696ef45b 100644
--- a/pkg/http/lib/src/multipart_file.dart
+++ b/pkg/http/lib/src/multipart_file.dart
@@ -80,14 +80,15 @@ class MultipartFile {
}
// TODO(nweiz): Infer the content-type from the filename.
- /// Creates a new [MultipartFile] from a [File].
+ /// Creates a new [MultipartFile] from a path to a file on disk.
///
- /// [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,
+ /// [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,
{String filename, ContentType contentType}) {
- if (filename == null) filename = new Path(file.name).filename;
+ if (filename == null) filename = path.basename(filePath);
+ var file = new File(filePath);
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 | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698