Package: effect
Module: SchemaTransformation
Decodes a Base64-encoded string into a Uint8Array and encodes a
Uint8Array back to a Base64 string.
When to use
Use when you need a schema transformation for binary data transmitted as Base64 strings (e.g. file uploads, API payloads).
Details
Decoding parses the Base64 string into bytes. Encoding writes the byte array as a Base64 string.
Example (Converting Base64 to a Uint8Array)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.String.pipe(
Schema.decodeTo(Schema.Uint8Array, SchemaTransformation.uint8ArrayFromBase64String)
)
See
fromJsonStringSchema.Uint8ArrayFromBase64 - a ready-made schema wrapping this transformation.Signature
declare const uint8ArrayFromBase64String: Transformation<Uint8Array<ArrayBufferLike>, string, never, never>
Since v4.0.0