MultipartReceiver

org.http4s.multipart.MultipartReceiver
See theMultipartReceiver companion trait

Attributes

Companion
trait
Source
MultipartReceiver.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final class At[F[_], A](name: String, receiver: PartReceiver[F, A])

Attributes

Source
MultipartReceiver.scala
Supertypes
class Object
trait Matchable
class Any

Types

type Aux[F[_], A, P] = MultipartReceiver[F, A] { type Partial = P; }

Attributes

Source
MultipartReceiver.scala

Value members

Concrete methods

def at[F[_], A](name: String, receiver: PartReceiver[F, A]): At[F, A]

Attributes

Source
MultipartReceiver.scala

Creates a MultipartReceiver which inspects each Part's headers to decide whether to receive each Part as text or as a file upload.

Creates a MultipartReceiver which inspects each Part's headers to decide whether to receive each Part as text or as a file upload.

Parts that look like file uploads will have their content written to a temp file, represented with PartValue.OfFile. All other parts will be decoded to text, represented with PartValue.OfString. Each part's name is used as a key in the resulting Map[String, PartValue].

Type parameters

F

The effect type

Attributes

Returns

A MultipartReceiver which builds a Map containing each Part, where the map's key is the part name, and value is the decoded part, represented as either plain text or as a temporary file.

Source
MultipartReceiver.scala
def uniform[F[_], A](partReceiver: PartReceiver[F, A]): Aux[F, List[A], A]

Creates a MultipartReceiver which handles all parts the same way, using the given partReceiver.

Creates a MultipartReceiver which handles all parts the same way, using the given partReceiver.

Note that the resulting MultipartReceiver does not inherently capture any metadata about each Part; only the decoded values are returned as a List. The given partReceiver can be constructed to provide the necessary metadata, e.g. by using PartReceiver.withPartName

Example usage:

val genericReceiver: MultipartReceiver[IO, Map[String, Stream[IO, Byte]]] =
 MultipartReceiver.uniform(
   PartReceiver
     .toMixedBuffer[IO](maxSizeBeforeFile = 10 * 1024 * 1024)
     .withPartName
 ).map(_.toMap)

The above passes a PartReceiver.toMixedBuffer to load part data into memory up to a certain per-part limit, dumping the buffer to a temporary file after that limit is reached. The buffer for each part is exposed as a generic byte stream which can safely be re-read until the underlying buffers are released. The withPartName method transforms the PartReceiver to include the Part name so we can return a convenient Map representation of the result.

Type parameters

A

The value type returned by the partReceiver

F

The effect type

Value parameters

partReceiver

The PartReceiver to use for each part

Attributes

Returns

A MultipartReceiver which delegates to the given partReceiver for all parts, returning a List of all parts' decoded values.

Source
MultipartReceiver.scala

Implicits

Implicits

implicit def multipartReceiverApplicative[F[_]]: Applicative[[_] =>> MultipartReceiver[F, _$15]]

Attributes

Source
MultipartReceiver.scala