(base64String string)
| 16 | ) |
| 17 | |
| 18 | func DecodeBase64ImageData(base64String string) (image.Config, string, string, error) { |
| 19 | // 去除base64数据的URL前缀(如果有) |
| 20 | if idx := strings.Index(base64String, ","); idx != -1 { |
| 21 | base64String = base64String[idx+1:] |
| 22 | } |
| 23 | |
| 24 | // 将base64字符串解码为字节切片 |
| 25 | decodedData, err := base64.StdEncoding.DecodeString(base64String) |
| 26 | if err != nil { |
| 27 | fmt.Println("Error: Failed to decode base64 string") |
| 28 | return image.Config{}, "", "", fmt.Errorf("failed to decode base64 string: %s", err.Error()) |
| 29 | } |
| 30 | |
| 31 | // 创建一个bytes.Buffer用于存储解码后的数据 |
| 32 | reader := bytes.NewReader(decodedData) |
| 33 | config, format, err := getImageConfig(reader) |
| 34 | return config, format, base64String, err |
| 35 | } |
| 36 | |
| 37 | func DecodeBase64FileData(base64String string) (string, string, error) { |
| 38 | var mimeType string |
no test coverage detected