mime
MIMEタイプの定義を扱い、MIMEマルチパートメディアタイプのストリームを処理するためのDartパッケージ。
- スター
- 128
- フォーク
- 49
- 最終プッシュ(UTC)
- 2024/10/01
- プロジェクト状態
- アーカイブ済み
元の README
以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/mime
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.
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.
// 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'));
使用している依存関係
依存関係一覧 2 件
- dart_flutter_team_lints開発用
^3.0.0 - test開発用
^1.16.6
プロジェクトに合うリポジトリを選ぶには?
用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。
- 名前・作者・説明で検索し、技術トピックで絞り込みます。
- スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
- 利用前に GitHub で README、ライセンス、Issues を確認します。
情報源と管理
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗