| 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,
|
|
|