redb.Route.DataFormats.Mime
4.7.2
Prefix Reserved
dotnet add package redb.Route.DataFormats.Mime --version 4.7.2
NuGet\Install-Package redb.Route.DataFormats.Mime -Version 4.7.2
<PackageReference Include="redb.Route.DataFormats.Mime" Version="4.7.2" />
<PackageVersion Include="redb.Route.DataFormats.Mime" Version="4.7.2" />
<PackageReference Include="redb.Route.DataFormats.Mime" />
paket add redb.Route.DataFormats.Mime --version 4.7.2
#r "nuget: redb.Route.DataFormats.Mime, 4.7.2"
#:package redb.Route.DataFormats.Mime@4.7.2
#addin nuget:?package=redb.Route.DataFormats.Mime&version=4.7.2
#tool nuget:?package=redb.Route.DataFormats.Mime&version=4.7.2
redb.Route.DataFormats.Mime
MIME multipart as a redb.Route data format, on MimeKit: Apache Camel's
mimeMultipart, with a form mode for multipart/form-data. The files of a form or of a multipart/mixed body become
message attachments, so the same route can send them on with smtp: or store them.
context.AddMimeMultipartDataFormat(); // multipart/form-data; builder.AddMimeMultipartDataFormat() with DI
From("http://0.0.0.0:8080/claims")
.ConvertBody<FormBody>() // driven by the request Content-Type
.SetHeader("claim", e => ((FormBody)e.In.Body!).Get("claim"))
.Filter("attachments.size > 0")
.To("smtp://mail.example.com?to=claims@example.com");
// per-node, without registering
.UnmarshalMimeMultipart()
.MarshalMimeMultipart(o => o.SubType = "mixed")
Unmarshal
| Body | Result |
|---|---|
not multipart/* (by the message content type or its Content-Type header) |
unchanged, as Camel does |
multipart/form-data |
body: FormBody with every field in order, repeated names kept (or Dictionary<string, string>, first value of each name); attachments: every part with a file name, named by that file name, part headers kept (the form field is in Content-Disposition); content type removed |
any other multipart/* |
body: the first part as byte[], string or a Stream, its type as the content type; attachments: the other parts, named by file name, then Content-ID, then a generated id |
- The boundary comes from the content type; without one, from the first line of the body.
- File names lose their directory (
C:\docs\a.pdfand../a.pdfgivea.pdf) and line breaks; a storage key is still the route's decision. filenameandfilename*(RFC 2231), quoted-printable and base64 parts are decoded; raw UTF-8 names from browsers are read as UTF-8.- A nested multipart or a
message/rfc822part stays one attachment with its bytes. - Parts are spooled to a
StreamCachewith the engine's stream cache options, so a large file does not stay in memory. The cache is released with the exchange: store or send the files before it ends (anhttp:consumer ends it once the response is written).
Marshal
SubType |
Body in | Out |
|---|---|---|
form-data (default) |
FormBody, string pairs or no body, plus the attachments |
multipart/form-data: one field per pair, one file part per attachment (field name from its Content-Disposition, else its name) |
mixed |
byte[], string or Stream with the message content type, plus the attachments |
multipart/mixed: the body first, then the attachments; without attachments the body is left as it is unless MultipartWithoutAttachment |
A new boundary per message goes into the content type and the Content-Type header, so http: sends it as it is.
The body becomes a StreamCache; the attachments stay on the message.
Options
| Option | Default | |
|---|---|---|
SubType |
form-data |
what Marshal writes and the format registers under: form-data or mixed |
MultipartWithoutAttachment |
false |
mixed: write a multipart without attachments |
MaxParts |
1000 | parts in one body |
MaxPartBytes |
10 MB | one decoded part |
MaxTotalBytes |
32 MB | the body as it arrives |
MaxFileNameLength |
255 | characters of a file name |
DefaultCharset |
UTF-8 | fields and headers that declare none |
The limits hold wherever the body comes from, not only behind a web server; a body over a limit fails the step with
InvalidDataException naming the limit. multipart/related is never registered: it belongs to SOAP MTOM.
XML form: register in context.xml with
<dataFormat type="redb.Route.DataFormats.Mime.MimeMultipartDataFormat, redb.Route.DataFormats.Mime"/>, then
<convertBody type="redb.Route.Serialization.FormBody, redb.Route"/> or <marshal format="multipart/form-data"/>.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0)
- JsonPath.Net (>= 2.2.0)
- JsonSchema.Net (>= 7.3.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- MimeKit (>= 4.18.1)
- redb.Route (>= 4.7.2)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
-
net8.0
- BouncyCastle.Cryptography (>= 2.7.0)
- JsonPath.Net (>= 2.2.0)
- JsonSchema.Net (>= 7.3.4)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- MimeKit (>= 4.18.1)
- redb.Route (>= 4.7.2)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
-
net9.0
- BouncyCastle.Cryptography (>= 2.7.0)
- JsonPath.Net (>= 2.2.0)
- JsonSchema.Net (>= 7.3.4)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- MimeKit (>= 4.18.1)
- redb.Route (>= 4.7.2)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.