GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.Base64Helper Class Reference

Helper class for base64 encoding/decoding and saving decoded content with sensible file extensions based on content type. Designed for backend use - no UI, no complex fluent API. More...

Public Member Functions

Base64Helper WithInput (string base64String)
 Sets the base64 input string to work with. Returns this instance for simple chaining: WithInput(...).SaveTo(...).
void SaveTo (GPALFile filename)
 Saves the decoded bytes to the specified file path. Uses the suggested extension if the filename lacks one or has a generic one.

Static Public Member Functions

static string EncodeToBase64 (string text)
 Encodes a plain string to base64 using UTF-8 encoding.
static string DecodeFromBase64 (string base64String)
 Decodes a base64 string to UTF-8 text. Throws if the result is not valid UTF-8 or input is invalid base64.
static string GuessExtensionFromBytes (byte[] bytes)

Properties

string SuggestedExtension [get]
 Returns the detected/suggested file extension for the decoded content. Useful for logging, UI hints, or constructing filenames.

Detailed Description

Helper class for base64 encoding/decoding and saving decoded content with sensible file extensions based on content type. Designed for backend use - no UI, no complex fluent API.

Definition at line 29 of file Base64Helper.cs.

Member Function Documentation

◆ DecodeFromBase64()

string GenerallyPositive.Base64Helper.DecodeFromBase64 ( string base64String)
static

Decodes a base64 string to UTF-8 text. Throws if the result is not valid UTF-8 or input is invalid base64.

Definition at line 106 of file Base64Helper.cs.

◆ EncodeToBase64()

string GenerallyPositive.Base64Helper.EncodeToBase64 ( string text)
static

Encodes a plain string to base64 using UTF-8 encoding.

Definition at line 95 of file Base64Helper.cs.

◆ GuessExtensionFromBytes()

string GenerallyPositive.Base64Helper.GuessExtensionFromBytes ( byte[] bytes)
static

Definition at line 132 of file Base64Helper.cs.

◆ SaveTo()

void GenerallyPositive.Base64Helper.SaveTo ( GPALFile filename)

Saves the decoded bytes to the specified file path. Uses the suggested extension if the filename lacks one or has a generic one.

Parameters
filenameFull path or filename to save to (e.g. "output.png", "C:\temp\doc.pdf")
Exceptions
InvalidOperationExceptionIf no input was set first
IOExceptionIf file cannot be written

Definition at line 74 of file Base64Helper.cs.

◆ WithInput()

Base64Helper GenerallyPositive.Base64Helper.WithInput ( string base64String)

Sets the base64 input string to work with. Returns this instance for simple chaining: WithInput(...).SaveTo(...).

Parameters
base64StringBase64-encoded data (may have whitespace)
Returns
This instance
Exceptions
ArgumentExceptionIf input is null/empty or invalid base64

Definition at line 43 of file Base64Helper.cs.

Property Documentation

◆ SuggestedExtension

string GenerallyPositive.Base64Helper.SuggestedExtension
get

Returns the detected/suggested file extension for the decoded content. Useful for logging, UI hints, or constructing filenames.

Definition at line 86 of file Base64Helper.cs.


The documentation for this class was generated from the following file: