p-hatan/ mirror

pub repository

mirror.p-hatan.com

mime

0.9.5

Helper-package for working with MIME.

Download archive

Readme

Package for working with MIME type definitions and for processing streams of MIME multipart media types.

Determining the MIME type for a file

The 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 using addExtension and addMagicNumber.

Processing MIME multipart media types

The class MimeMultipartTransformer is used to process a Stream of bytes encoded using a MIME multipart media types encoding. The transformer provides a new Stream of 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.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.9.5

  • Add support for the WebAssembly format.

0.9.4

  • Updated Dart SDK requirement to >= 1.8.3 <2.0.0

  • Strong-mode clean.

  • Added support for glTF text and binary formats.

0.9.3

  • Fixed erroneous behavior for listening and when pausing/resuming stream of parts.

0.9.2

  • Fixed erroneous behavior when pausing/canceling stream of parts but already listened to one part.

0.9.1

  • Handle parsing of MIME multipart content with no parts.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add mime
pubspec.yaml
name: mime
version: 0.9.5
author: Dart Team <misc@dartlang.org>
description: Helper-package for working with MIME.
homepage: https://www.github.com/dart-lang/mime
environment:
  sdk: '>=1.8.3 <2.0.0'
dev_dependencies:
  test: '^0.12.0'

Version history

VersionPublishedArchiveSHA-256
0.6.12013-06-27T19:33:45.263350ZDownload6ee181031a4ac16f0c9c9bfd585de1d70f1b6641b2cfcf128089e64a1a624534
0.6.22013-06-28T20:56:35.988740ZDownload37225860a0b2cea3292ba280dcbb50ab80c6b5693e90684591c1825ce53ad864
0.6.3+12013-07-09T00:24:36.882900ZDownload51368e46f885634e577df8bc924a07c877a680cfadf20f80a07fab1dd7ceffef
0.6.52013-07-16T00:21:21.184600ZDownloadafbc7246ab3e611b0c7fc2957547d81876336a95a0315155c2adcb8d7b6ca54c
0.6.62013-07-17T19:42:23.655380ZDownload55b19d3b03f077314f344e1bae34bec832bc815d313dabb0cbdac4423d42c3af
0.6.82013-07-19T20:56:09.736070ZDownload4346d4c50df919965e17084bad8b146d1c6122b97a8fe5afa5ffb6de34c2cd64
0.6.92013-07-22T15:15:29.719470ZDownloadbae5a49971ae562a34aafd8051ee16c50c8292b58fec2543a28ccf86e58a9723
0.6.9+22013-07-24T03:59:14.440920ZDownload5714efb2076901b1ac817a7c18d9a49aa88d462fe923d284de80a663506a41ce
0.6.112013-07-25T05:10:15.536610ZDownload64c04fe46076a084f2a70466b1ec6c05a8b8ad423aaf49ea715872a5cbff5c1a
0.6.122013-07-26T20:07:08.294850ZDownload3bb43d32e230108ec8024da841ddc30308049666529bb7a9c87518ceb84e62d2
0.6.132013-07-30T21:56:41.729360ZDownload143d06fbf5d8bd43bf9be9c633124313bce0318be15ebda215037f0bc2b70835
0.6.142013-08-02T16:25:57.127250ZDownload99d52a263beee34d565992b6a7555bc7dd0b3149c91ec51457e2e36365ff85da
0.6.15+22013-08-05T22:50:25.942490ZDownloadd6916124912bfad09b7fe86634249a5581dea08072f961707538a48f9af6f0b9
0.6.15+32013-08-06T20:13:33.923030ZDownloade2c6130fde60bac3cfc51299e8dc281a8a25ad98d6f15ac68794bb32c7b66c54
0.6.172013-08-10T17:35:58.798620ZDownload41e642af929612d66be9387fd3dd4f5d458b8b8587ee917cf29493814290fc44
0.6.17+22013-08-12T22:22:36.750740ZDownload661b8f3587a3fd072d49b86780020a84c237c6bc7e53d737810056996ea2ddac
0.6.192013-08-19T16:11:26.885240ZDownload1e4683de1d883085e00017f4e9d93263fc41787bae4d48e95659ee369613100d
0.6.20+12013-08-22T18:19:54.973590ZDownloadd56338d0fa45c84e2727ef5b2092102a71f46969a3ed41e510fc6b98664914ce
0.6.21+32013-08-26T17:43:32.542790ZDownloadaa71af46569ae14b34c54cd57a9ccd9e01eca134ab409021cc2e59d5af163c4d
0.7.02013-08-28T19:29:34.863320ZDownloadfe60b88ed6b250f59bb1e01f8f829bbbfe3955bdefc2d16f8e596d2e95772ba7
0.7.12013-09-03T15:52:53.334760ZDownloaddaa8ac3b76bfe02bef146542dda00838521cf85ba600dc978f26056634ba06de
0.7.22013-09-06T15:51:59.989340ZDownloadfdf1939970852d5ccb79584f47c105b55dd3361936965f6e8ae8d2ec9c9176f3
0.7.2+12013-09-08T15:48:00.055170ZDownload42d150ed2401421e40167c956654f09f2b33a4149a60fa55d08dbf098fbc79c3
0.7.3+12013-09-16T15:44:48.121610ZDownloadbe42b0ed632168c7a87e72a510665769bf4aab4e8b3f4bff3159db20b4a11b05
0.7.42013-09-18T03:04:27.236690ZDownload5c20131a25fb4a14a762f65b7b3243458ccbec09fc8f6583776e5f8f378f08d9
0.7.52013-09-21T00:42:44.445390ZDownload36874b6f0edc074243f7fc5e6a5583d2e06db25b9a8fc8ce5e02eacb3839c931
0.7.62013-09-27T14:58:15.246910ZDownload97788e5c35ba4386c2db17e74cc4ccd972b598fa87a7352976525b2dd78b7ceb
0.7.6+42013-10-01T23:49:19.862410ZDownloade2210cfc74591b88501ccf311c86b36e01bbe5885e7cc517ea039988aaf1cb51
0.8.02013-10-03T16:28:12.322070ZDownload044bd754e39f7fc0c7219d1b802d3da7acb1328a76a295729915a7b5e769838e
0.8.12013-10-04T21:54:53.488950ZDownload31abab3267a32dc387808be5d36f81ec48e942b3ec0dff3859bfd6d124e198ee
0.8.22013-10-14T21:42:38.071070ZDownload88b22305cfccdf274536da49c69fb5e66fe420048d8458dcd55f71c85bf36ab6
0.8.32013-10-17T16:01:06.826190ZDownload2ccce8f63001b8eb09a2fba2190cbd3ef585defb2847c1a27fce1161d87dd3ce
0.8.42013-10-19T21:09:14.659460ZDownload4c250db5422f27a35fc17f182423f4cc1bacaeb8acc249530b23396efd23a43b
0.8.52013-10-21T15:50:57.908780ZDownloadea20982b8a21173aab90dfa3ecdfeb66e6b379331dc8931664398994569bb47f
0.8.62013-10-24T08:19:39.812590ZDownload8ddf0ad1586715cc542566810d1ec19a3df926c03b5a1582c23ec1144044aecc
0.8.72013-10-28T14:34:08.602650ZDownload2b3b6be4dda0924a3201082077c51b93d72587f2343414479d32cea21cb9679a
0.8.82013-10-30T03:29:55.009800ZDownloadc9d6fc8274fc9b398262da177bec0754cacc9659cc988a488894c5fe44968e1e
0.8.92013-10-31T15:16:19.429980ZDownload3a1749da3dd52a959fbecac28d07164d98c8d4da1a0747f539d8d1357e3175e7
0.8.102013-11-01T19:23:39.000260ZDownload6ca11b69b12ff29609ebe76ac441bb7dc0cfac38527f0bb65afcf0b068b1ecc5
0.8.10+32013-11-04T16:49:40.150690ZDownloada6d6bcd704f72525d68f5dd0895617d9a293ae738f14c7e3e524410a8c1f64eb
0.8.10+42013-11-05T16:05:50.108110ZDownload67386eb03fdec74c0dce26204f0d7513050899515ec8ae3259f44ed9fec65563
0.9.02013-11-06T19:32:08.050300ZDownload99486ac41cea50a4fbc6fb4ee349e52707be50c85f6ffcee9db77c49ef018035
0.9.0+12014-05-13T18:24:51.661850ZDownload06dbd318f03a4adabd9dde52859ae2fda9f20be2d87472d06ae12d0dc7ac7667
0.9.0+32014-05-30T17:40:42.439720ZDownload5e426baa255a9ad32a57e02dd95ed02c66c40e8f7d6e1aa4b109b54024a0db4f
0.9.12014-12-03T18:53:31.012810ZDownload751e254ee14a8f2fa5dc52a06415ab15cb2212b88ed7d278f88651c88d401e59
0.9.22015-02-12T13:54:57.737040ZDownload2419e768ae65a51d4b401a5cd4a88cb830477b8842370a2c62449a5d4336de1b
0.9.32015-02-18T14:46:26.477820ZDownload6f2da7f8ae179b624f8e14cb36761868452761d6af287f86dc9cc5632e947d49
0.9.42017-10-25T17:37:49.202461ZDownloadf1fd96443f6d7f5b7813fa314334c54bec634427f6eca00b73de0351a28e6c30
0.9.52017-12-07T23:08:23.406761ZDownloadd51ed8b1b3493100f62f8eaf883d0b7c10098a75ce1947fb2b2755b2378d9a78
0.9.62018-02-01T21:00:10.709102ZDownload2ad7238cb3b28d9dce47589276c4c0c21efa751fd50e32797ffeb746dc8abc29
0.9.6+12018-05-15T20:27:57.183088ZDownload89748db1ed225d232b8eaa82a365b92f5cf27858cda1db4ff151c2d6d428ac9f
0.9.6+22018-07-20T21:44:33.107005ZDownloadc2d2eb570ca85d3429026f2b1b3a4791489e9480c043f0c9dce789c37472144c
0.9.6+32019-05-29T19:04:38.377048ZDownload502904712fde940e05c73737450fcfc1f3bb8fa4dab6e69c54e1b558d4ca5ad9
0.9.72020-08-11T03:03:05.393755ZDownload5041f313f4e30fbd70dee7c0403785a4ee270f75830f590e5983960fddf743e4
1.0.0-nullsafety.02020-12-08T21:24:14.773412ZDownload0782700d8abb2d86cac41b5fee30897f029a58ee1199ca7c3207695979a33522
1.0.02021-02-05T19:05:20.814565ZDownloada7a98ea7f366e2cc9d2b20873815aebec5e2bc124fe0da9d3f7f59b0625ea180
1.0.12021-10-18T14:16:05.870392ZDownloadfd5f81041e6a9fc9b9d7fa2cb8a01123f9f5d5d49136e06cb9dc7d33689529f4
1.0.22022-05-02T20:47:14.136138ZDownloaddab22e92b41aa1255ea90ddc4bc2feaf35544fd0728e209638cad041a6e3928a
1.0.32022-11-29T21:03:19.720158ZDownload52e38f7e1143ef39daf532117d6b8f8f617bf4bcd6044ed8c29040d20d269630
1.0.42023-01-12T00:48:25.596638ZDownloade4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
1.0.52024-01-24T22:13:10.934726ZDownload2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2
1.0.62024-08-26T16:13:38.589265ZDownload801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a
2.0.02024-09-30T17:12:15.400930ZDownload41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6
2.1.02026-08-28T20:42:27.296992ZDownloadbd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6

Dependencies

No direct dependencies declared.