Skip to content

Instantly share code, notes, and snippets.

@Kilowhisky
Last active July 19, 2021 16:22
Show Gist options
  • Save Kilowhisky/9a00310352ae5bd13a15c5683e2c2ed1 to your computer and use it in GitHub Desktop.
Save Kilowhisky/9a00310352ae5bd13a15c5683e2c2ed1 to your computer and use it in GitHub Desktop.
DataUrl to Binary Converter
private (string type, byte[] data) DataUrlToBinary(string dataUrl)
{
var match = Regex.Match(dataUrl, @"data:(?<type>.+?);base64,(?<data>.+)");
var type = match.Groups["type"].Value;
var base64Data = match.Groups["data"].Value;
var binData = Convert.FromBase64String(base64Data);
return (type, binData);
}
@Kilowhisky
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment