Structure
StreamingMultipartWriterAsyncSequence
An async sequence that converts a sequence of
MultipartSection values into serialized multipart data chunks.struct StreamingMultipartWriterAsyncSequence<OutboundBody, BackingSequence, BackingBody> where OutboundBody : RangeReplaceableCollection, OutboundBody : Sendable, BackingSequence : AsyncSequence, BackingBody : RangeReplaceableCollection, BackingBody : Sendable, OutboundBody.Element == UInt8, BackingSequence.Element == MultipartSection<BackingBody>, BackingBody.Element == UInt8
Overview
This streaming writer processes multipart sections on-demand, making it memory-efficient for large multipart messages. It’s particularly useful when working with file uploads or when you need to stream multipart data without buffering the entire message in memory.
let sections: [MultipartSection<ArraySlice<UInt8>>] = [
.headerFields([.contentType: "text/plain"]),
.bodyChunk(ArraySlice("Hello, world!".utf8)),
.boundary(end: true)
]
let writer = StreamingMultipartWriterAsyncSequence(
backingSequence: sections.async,
boundary: "boundary123"
)
for try await chunk in writer {
// Process each serialized chunk
}
Topics
Structures
StreamingMultipartWriterAsyncSequence.AsyncIteratorThe async iterator for the streaming multipart writer.
Initializers
init(backingSequence:boundary:outboundBody:)Creates a new streaming multipart writer async sequence.
Instance Methods
makeAsyncIterator()Creates the asynchronous iterator that produces elements of this asynchronous sequence.
Relationships
Conforms To
_Concurrency.AsyncSequence