Package for working with MIME type definitions and for processing streams of MIME multipart media types.
MimeTypeResolver class can be used to determine the MIME type of
a file. It supports both using the extension of the file name and
looking at magic bytes from the beginning of the file.
There is a builtin instance of
MimeTypeResolver accessible through
the top level function
lookupMimeType. This builtin instance has
the most common file name extensions and magic bytes registered.
print(lookupMimeType('test.html')); // Will print text/html print(lookupMimeType('test', [0xFF, 0xD8])); // Will print image/jpeg print(lookupMimeType('test.html', [0xFF, 0xD8])); // Will print image/jpeg
You can build you own resolver by creating an instance of
MimeTypeResolver and adding file name extensions and magic bytes
MimeMultipartTransformer is used to process a
bytes encoded using a MIME multipart media types encoding. The
transformer provides a new
MimeMultipart objects each of
which have the headers and the content of each part. The content of a
part is provided as a stream of bytes.
Below is an example showing how to process an HTTP request and print the length of the content of each part.
// HTTP request with content type multipart/form-data. HttpRequest request = ...; // Determine the boundary form the content type header String boundary = request.headers.contentType.parameters['boundary']; // Process the body just calculating the length of each part. request .transform(new MimeMultipartTransformer(boundary)) .map((part) => part.fold(0, (p, d) => p + d)) .listen((length) => print('Part with length $length'));
Take a look at the
HttpBodyHandler in the http_server
package for handling different content types in an HTTP request.
Please file feature requests and bugs at the issue tracker.
<3.0.0, and adjust other dependencies.
Updates to support Dart 2.0 core library changes (wave 2.2). See issue 31847 for details.
Updated Dart SDK requirement to
>= 1.8.3 <2.0.0
Added support for glTF text and binary formats.
Add this to your package's pubspec.yaml file:
dependencies: mime: ^0.9.6+2
You can install packages from the command line:
$ pub get
$ flutter packages get
Alternatively, your editor might support
pub get or
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.9.6+2||Jul 20, 2018|
|0.9.6+1||May 15, 2018|
|0.9.6||Feb 1, 2018|
|0.9.5||Dec 7, 2017|
|0.9.4||Oct 25, 2017|
|0.9.3||Feb 18, 2015|
|0.9.2||Feb 12, 2015|
|0.9.1||Dec 3, 2014|
|0.9.0+3||May 30, 2014|
|0.9.0+1||May 13, 2014|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, web, other
No platform restriction found in primary library
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*, it usually means that the author is still experimenting with the general direction of the API.
Maintain an example.
Create a short demo in the
example/ directory to show how to use this package. Common file name patterns include:
example.dart or you could also use
|Dart SDK||>=2.0.0-dev.20.0 <3.0.0|