Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.uint8ArrayFromBase64Stringconsteffect/SchemaTransformation.ts:1443
Transformation<Uint8Array<ArrayBufferLike>, string, never, never>

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)
)
export const uint8ArrayFromBase64String: Transformation<Uint8Array<ArrayBufferLike>, string> = new Transformation(
  SchemaGetter.decodeBase64(),
  SchemaGetter.encodeBase64()
)
Referenced by 2 symbols