|
|
|
@ -376,18 +376,18 @@ func DecodeBase64Image(url string) (bytes []byte, extension string, err error) {
@@ -376,18 +376,18 @@ func DecodeBase64Image(url string) (bytes []byte, extension string, err error) {
|
|
|
|
|
s := strings.SplitN(url, ",", 2) |
|
|
|
|
if len(s) < 2 { |
|
|
|
|
err = errors.New("error splitting base64 image data") |
|
|
|
|
return |
|
|
|
|
return nil, "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bytes, err = base64.StdEncoding.DecodeString(s[1]) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
return nil, "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
splitHeader := strings.Split(s[0], ":") |
|
|
|
|
if len(splitHeader) < 2 { |
|
|
|
|
err = errors.New("error splitting base64 image header") |
|
|
|
|
return |
|
|
|
|
return nil, "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
contentType := strings.Split(splitHeader[1], ";")[0] |
|
|
|
@ -404,7 +404,7 @@ func DecodeBase64Image(url string) (bytes []byte, extension string, err error) {
@@ -404,7 +404,7 @@ func DecodeBase64Image(url string) (bytes []byte, extension string, err error) {
|
|
|
|
|
|
|
|
|
|
if extension == "" { |
|
|
|
|
err = errors.New("missing or invalid contentType in base64 image") |
|
|
|
|
return |
|
|
|
|
return nil, "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return bytes, extension, nil |
|
|
|
|