Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
2458318
Add a new MIME-type package 'mime', with implementation for handling …
Jun 24, 2013
2a0d441
Fix 'part of' for mime package.
Jun 24, 2013
ca949d5
Move MimeMultipartTransformer and HttpBodyHandler to mime and http_se…
Jul 15, 2013
2ea7b3a
Fix editor warnings in http_server and mime.
Jul 15, 2013
ed04ff2
Run mime-multipart test in 'test' callback.
Jul 15, 2013
9e20bcf
pkg: analysis aided cleanup
kevmoo Aug 6, 2013
8d8de0d
mime library description
kwalrath Aug 27, 2013
acb98ee
Adapt streams for additional stackTrace argument.
floitschG Oct 11, 2013
b752bfb
Use UTF8-decoding for headers in mime multipart parser.
Oct 30, 2013
a09e437
add versions and constraints for packages and samples
Nov 6, 2013
bdec886
Revert "add versions and constraints for packages and samples"
Nov 6, 2013
ee8ef9d
Re-land r29957 (add versions and constraints for packages and samples…
dgrove Nov 6, 2013
f6f6d0c
pkg/unittest: added LICENSE
kevmoo Jan 13, 2014
083c31b
pkg/mime: formatting, finals, consts, etc
kevmoo Jan 28, 2014
69a3038
pkg/mime: layout as mini-libraries
kevmoo May 13, 2014
586e7e3
Clean up mime package.
May 23, 2014
17b4eeb
pkg/mime: Removed mutable state from MimeMultipartTransformer
kevmoo May 30, 2014
3e6e648
Handle multipart MIME parsing with no parts
sgjesse Nov 18, 2014
57180b6
Fix multipart transformer in package:mime
mkustermann Feb 12, 2015
fb24c4c
Fix bug in subscription handling in mime package
sgjesse Feb 18, 2015
3e92b98
Add README file to the mime package
sgjesse Feb 18, 2015
361f264
Update project to match OSS template
sgjesse Feb 24, 2015
017f46d
Add .gitignore and empty .status
sgjesse Feb 24, 2015
1be80da
Update .status for mime package
sgjesse Feb 24, 2015
20ebc85
ignore .packages file
kevmoo Aug 26, 2015
c664d4b
Use pkg/test
kevmoo Aug 26, 2015
bf90449
dartfmt most of the code
kevmoo Aug 26, 2015
cb62233
cleanup unused members in test
kevmoo Aug 27, 2015
2097262
Update bot configuration to use test package
kevmoo Aug 27, 2015
e5b74ab
Make package mime strong clean
keertip Dec 9, 2016
692cb13
Travis ci (dart-lang/mime#8)
kevmoo Sep 11, 2017
d5ed77c
Adds support for glTF - text and binary formats (dart-lang/mime#9)
mfrancis107 Oct 18, 2017
2075020
Update readme
kevmoo Oct 25, 2017
a0b20b2
Prepare for 0.9.4
kevmoo Oct 25, 2017
f38e11c
Add WebAssembly extension (dart-lang/mime#12)
thegregorator Dec 7, 2017
0a4a8d1
Updates for Dart 2.0 core library changes (wave 2.2)
leafpetersen Jan 31, 2018
db4360f
Remove stable from travis
leafpetersen Jan 31, 2018
2d10bdf
Merge pull request dart-lang/mime#16 from dart-lang/corelib_2_2
leafpetersen Feb 1, 2018
c203588
Remove upper case constants (dart-lang/mime#17)
lrhn May 4, 2018
faa484b
Update .gitignore to new `dart_tool` pub cache
bcko May 24, 2018
1830814
Merge pull request dart-lang/mime#18 from bcko/patch-1
devoncarew May 28, 2018
9d7f558
Update README.md (dart-lang/mime#20)
devoncarew Jul 17, 2018
2c62d78
Allow SDK versions <3.0.0 (dart-lang/mime#21)
chalin Jul 20, 2018
69a31d0
change the mime type for dart source (dart-lang/mime#19)
devoncarew Jul 22, 2018
0c5e1c8
Delete codereview.settings
kevmoo May 29, 2019
a4372e0
Fix URLs
kevmoo May 29, 2019
21333f3
enable and fix a number of lints
kevmoo May 29, 2019
35be08c
Test on oldest supported SDK
kevmoo May 29, 2019
52fd1c7
Remove gratuitous self-link
kevmoo May 29, 2019
e4eccdc
Add more details to package description
kevmoo May 29, 2019
365ac8f
Add example, fix readme
kevmoo May 29, 2019
294b59e
Prepare to release 0.9.6+3
kevmoo May 29, 2019
d42ee29
Fix latest lints, remove author from pubspec (dart-lang/mime#30)
kevmoo Dec 9, 2019
f0d744b
Add `extensionFromMime` utility.
kenzieschmoll Aug 10, 2020
d7ac049
review comments
kenzieschmoll Aug 10, 2020
ddd7440
Merge pull request dart-lang/mime#33 from kenzieschmoll/extensionFrom…
kenzieschmoll Aug 10, 2020
c550748
pubspec.yaml: fix homepage
kevmoo Sep 15, 2020
77c3436
Remove unneeded dart:async import
MichaelRFairhurst Sep 22, 2020
8765cf7
Merge pull request dart-lang/mime#34 from MichaelRFairhurst/remove-im…
MichaelRFairhurst Sep 28, 2020
87aa2cc
Cleanup in BoundMultipartStream (dart-lang/mime#35)
natebosch Nov 13, 2020
387d5d2
Delete .test_config
kevmoo Nov 13, 2020
e40a103
migrate to null safety (dart-lang/mime#37)
jakemac53 Dec 8, 2020
2d741bf
Migrate to GitHub Actions (dart-lang/mime#40)
athomas Feb 1, 2021
30c3847
stable null safety release (dart-lang/mime#41)
jakemac53 Feb 5, 2021
715561f
Small change to LICENSE
franklinyow Mar 30, 2021
bdd2edf
Merge pull request dart-lang/mime#44 from dart-lang/franklinyow-patch-1
franklinyow Mar 30, 2021
81be76b
CI: latest setup, test oldest supported (dart-lang/mime#45)
kevmoo Apr 20, 2021
ed4d678
Fix newly enforced lint (dart-lang/mime#46)
kevmoo Apr 26, 2021
3ee07cc
Enable and fix a number of lints (dart-lang/mime#49)
kevmoo Jun 21, 2021
72f41e8
Add magic numbers for WebP (dart-lang/mime#54)
rodineijf Oct 18, 2021
50caca4
Move to pkg:lints, tiny bumps in deps (dart-lang/mime#56)
kevmoo Oct 18, 2021
ff1b881
Add magic numbers for AIFF, WAVE and FLAC files (dart-lang/mime#53)
hannesbraun Feb 10, 2022
b9e1938
Add `audio/m4p` mimeType lookup by file path (dart-lang/mime#62)
nilsreichardt Mar 22, 2022
4cdf69f
Add repository to pubspec (dart-lang/mime#63)
devoncarew May 2, 2022
17f9897
update action versions; add dependabot config (dart-lang/mime#69)
devoncarew Sep 26, 2022
72658a5
Bump actions/checkout from 3.0.2 to 3.1.0 (dart-lang/mime#72)
dependabot[bot] Nov 1, 2022
ebb7cac
Add .avif to extension map (dart-lang/mime#70)
mgenware Nov 2, 2022
d6aa206
Add `image/heic` mime type (dart-lang/mime#58)
aliasgarlabs Nov 15, 2022
90f5cc2
Add application/toml mimeType lookup by file path (dart-lang/mime#64)
hannesbraun Nov 15, 2022
176f964
Add woff2 mime type (dart-lang/mime#43)
simolus3 Nov 15, 2022
e0fb5cc
Add image/heif to extension map (dart-lang/mime#52)
zi6xuan Nov 15, 2022
9031027
Improve handling for audio: aac, mp3, ogg, webm (dart-lang/mime#57)
cedvdb Nov 15, 2022
a9cede8
Add .webmanifest to extension map (dart-lang/mime#29)
jman294 Nov 15, 2022
cd28ae2
Add .msj (and change .js) to text/javascript (dart-lang/mime#76)
kevmoo Dec 12, 2022
62e5f50
blast_repo fixes (dart-lang/mime#79)
kevmoo Dec 12, 2022
7a65624
Update to latest lints, bump min SDK to 2.18 (dart-lang/mime#77)
kevmoo Dec 12, 2022
374e194
Add .dcm to extension map (dart-lang/mime#74)
tomk9 Dec 13, 2022
bc8dc45
Prepare to release v1.0.4 (dart-lang/mime#80)
kevmoo Jan 12, 2023
0e76b39
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/mime#83)
dependabot[bot] Feb 1, 2023
58bc283
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/mime#82)
dependabot[bot] Feb 1, 2023
2963937
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/mime#91)
dependabot[bot] Apr 3, 2023
c8089ad
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/mime#90)
dependabot[bot] Apr 3, 2023
5cae2dd
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/mime#93)
dependabot[bot] May 8, 2023
4e5bf5a
Add `text/markdown` mimeType lookup by extension (dart-lang/mime#85)
literallylara May 9, 2023
2307b6d
Add m4b mime type (dart-lang/mime#92)
vorte May 9, 2023
0d93a16
blast_repo fixes (dart-lang/mime#95)
devoncarew May 10, 2023
d8bcb85
blast_repo fixes (dart-lang/mime#97)
devoncarew May 23, 2023
3e3071e
Improve the detection of mp4 types dart-lang/mime#86 (dart-lang/mime#98)
ivangolubykh May 26, 2023
268153c
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/mime#99)
dependabot[bot] Jul 1, 2023
45678ca
blast_repo fixes (dart-lang/mime#100)
kevmoo Jul 18, 2023
3a363b2
update lints, require Dart 3 (dart-lang/mime#101)
kevmoo Jul 18, 2023
7acfa88
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/mime#104)
dependabot[bot] Sep 1, 2023
0e23c58
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/mime#105)
dependabot[bot] Oct 1, 2023
100efb5
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/mime#106)
dependabot[bot] Oct 3, 2023
7639296
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/mime#107)
dependabot[bot] Nov 1, 2023
def44d5
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/mime#108)
dependabot[bot] Nov 1, 2023
82608bc
Detect HEIC/HEIF format by checking header bytes (dart-lang/mime#109)
CORDEA Dec 4, 2023
a1ed747
Bump actions/stale from 8.0.0 to 9.0.0 (dart-lang/mime#111)
dependabot[bot] Jan 1, 2024
4a5d04b
Update to latest lints, require Dart 3.2 (dart-lang/mime#114)
kevmoo Jan 24, 2024
9928e0e
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/mime#115)
dependabot[bot] Feb 1, 2024
b4522c5
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/mime#117)
dependabot[bot] Apr 1, 2024
33195d7
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/mime#119)
dependabot[bot] May 1, 2024
3bdb27e
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/mime#120)
dependabot[bot] May 1, 2024
ede8594
Bump actions/checkout from 4.1.4 to 4.1.6 (dart-lang/mime#124)
dependabot[bot] Jun 1, 2024
c77409b
Add `topics` to `pubspec.yaml` (dart-lang/mime#126)
szakarias Jun 10, 2024
7386496
Add `topics` to `pubspec.yaml` (dart-lang/mime#121)
jonasfj Jun 24, 2024
97391b1
bump lints (dart-lang/mime#127)
kevmoo Jun 24, 2024
39fc507
Bump actions/checkout from 4.1.6 to 4.1.7 (dart-lang/mime#129)
dependabot[bot] Jul 1, 2024
4dd459a
blast_repo fixes (dart-lang/mime#131)
kevmoo Jul 1, 2024
948fe28
Merge package:mime into shared tool repository
mosuem Aug 26, 2024
e40be87
Fixes for merging mime
mosuem Aug 26, 2024
86c7592
Ready for publish
mosuem Aug 26, 2024
350cb17
Add license header
mosuem Aug 26, 2024
49acd78
Fix analysis issue
mosuem Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/mime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dart CI

on:
schedule:
# “At 00:00 (UTC) on Sunday.”
- cron: '0 0 * * 0'
push:
branches: [ main ]
paths:
- '.github/workflows/mime.yml'
- 'pkgs/mime/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/mime.yml'
- 'pkgs/mime/**'

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: pkgs/mime/

strategy:
matrix:
os: [ubuntu-latest]
sdk: [3.2, dev]
steps:
# These are the latest versions of the github actions; dependabot will
# send PRs to keep these up-to-date.
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672

- name: Install dependencies
run: dart pub get

- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .

- name: Analyze project source
run: dart analyze --fatal-infos

- name: Run tests
run: dart test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ don't naturally belong to other topic monorepos (like
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |
| [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) |
| [oauth2](pkgs/oauth2/) | A client library for authenticatingand making requests via OAuth2. | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) |
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types. | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |

## Publishing automation

Expand Down
5 changes: 5 additions & 0 deletions pkgs/mime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.packages
.dart_tool/
.pub/
packages
pubspec.lock
6 changes: 6 additions & 0 deletions pkgs/mime/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
105 changes: 105 additions & 0 deletions pkgs/mime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
## 1.0.6

* Add `topics` section to `pubspec.yaml`.
* Move to `dart-lang/tools` monorepo.

## 1.0.5

* Update `video/mp4` mimeType lookup by header bytes.
* Add `image/heic` mimeType lookup by header bytes.
* Add `image/heif` mimeType lookup by header bytes.
* Add m4b mimeType lookup by extension.
* Add `text/markdown` mimeType lookup by extension.
* Require Dart 3.2.0.

## 1.0.4

* Changed `.js` to `text/javascript` per
https://datatracker.ietf.org/doc/html/rfc9239.
* Added `.mjs` as `text/javascript`.
* Add `application/dicom` mimeType lookup by extension.
* Require Dart 2.18.

## 1.0.3

* Add application/manifest+json lookup by extension.
* Add application/toml mimeType lookup by extension.
* Add audio/aac mimeType lookup by header bytes.
* Add audio/mpeg mimeType lookup by header bytes.
* Add audio/ogg mimeType lookup by header bytes.
* Add audio/weba mimeType lookup by header bytes.
* Add font/woff2 lookup by extension and header bytes.
* Add image/avif mimeType lookup by extension.
* Add image/heic mimeType lookup by extension.
* Add image/heif mimeType lookup by extension.
* Change audio/x-aac to audio/aac when detected by extension.

## 1.0.2

* Add audio/x-aiff mimeType lookup by header bytes.
* Add audio/x-flac mimeType lookup by header bytes.
* Add audio/x-wav mimeType lookup by header bytes.
* Add audio/mp4 mimeType lookup by file path.

## 1.0.1

* Add image/webp mimeType lookup by header bytes.

## 1.0.0

* Stable null safety release.

## 1.0.0-nullsafety.0

* Update to null safety.

## 0.9.7

* Add `extensionFromMime` utility function.

## 0.9.6+3

* Change the mime type for Dart source from `application/dart` to `text/x-dart`.
* Add example.
* Fix links and code in README.

## 0.9.6+2

* Set max SDK version to `<3.0.0`, and adjust other dependencies.

## 0.9.6+1

* Stop using deprecated constants from the SDK.

## 0.9.6

* Updates to support Dart 2.0 core library changes (wave
2.2). See [issue 31847][sdk#31847] for details.

[sdk#31847]: https://github.com/dart-lang/sdk/issues/31847

## 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.
33 changes: 33 additions & 0 deletions pkgs/mime/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Want to contribute? Great! First, read this page (including the small print at
the end).

### Before you contribute
Before we can use your code, you must sign the
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
(CLA), which you can do online. The CLA is necessary mainly because you own the
copyright to your changes, even after your contribution becomes part of our
codebase, so we need your permission to use and distribute your code. We also
need to be sure of various other things—for instance that you'll tell us if you
know that your code infringes on other people's patents. You don't have to sign
the CLA until after you've submitted your code for review and a member has
approved it, but you must do it before we can put your code into our codebase.

Before you start working on a larger contribution, you should get in touch with
us first through the issue tracker with your idea so that we can help out and
possibly guide you. Coordinating up front makes it much easier to avoid
frustration later on.

### Code reviews
All submissions, including submissions by project members, require review.

### File headers
All files in the project must start with the following header.

// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

### The small print
Contributions made by corporations are covered by a different agreement than the
one above, the
[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate).
27 changes: 27 additions & 0 deletions pkgs/mime/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2015, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 changes: 59 additions & 0 deletions pkgs/mime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/mime.yml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/mime.yml)
[![Pub Package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime)
[![package publisher](https://img.shields.io/pub/publisher/mime.svg)](https://pub.dev/packages/mime/publisher)

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.

```dart
import 'package:mime/mime.dart';

void main() {
print(lookupMimeType('test.html'));
// text/html

print(lookupMimeType('test', headerBytes: [0xFF, 0xD8]));
// image/jpeg

print(lookupMimeType('test.html', headerBytes: [0xFF, 0xD8]));
// 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.

```dart
// 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'));
```
34 changes: 34 additions & 0 deletions pkgs/mime/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# https://dart.dev/tools/analysis#the-analysis-options-file
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_this
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- join_return_with_assignment
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- unnecessary_await_in_return
- unnecessary_breaks
- unnecessary_raw_strings
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
16 changes: 16 additions & 0 deletions pkgs/mime/example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:mime/mime.dart';

void main() {
print(lookupMimeType('test.html'));
// text/html

print(lookupMimeType('test', headerBytes: [0xFF, 0xD8]));
// image/jpeg

print(lookupMimeType('test.html', headerBytes: [0xFF, 0xD8]));
// image/jpeg
}
14 changes: 14 additions & 0 deletions pkgs/mime/lib/mime.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Help for working with file format identifiers
/// such as `text/html` and `image/png`.
///
/// More details, including a list of types, are in the Wikipedia article
/// [Internet media type](http://en.wikipedia.org/wiki/Internet_media_type).
library;

export 'src/mime_multipart_transformer.dart';
export 'src/mime_shared.dart';
export 'src/mime_type.dart';
Loading