Last active
July 19, 2021 16:22
-
-
Save Kilowhisky/9a00310352ae5bd13a15c5683e2c2ed1 to your computer and use it in GitHub Desktop.
DataUrl to Binary Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on this https://gist.github.com/vbfox/484643