Untitled

 avatar
unknown
golang
2 years ago
382 B
4
Indexable
func getBase64String(image string) string {
	// Read the image file
	imageData, err := ioutil.ReadFile(image)
	if err != nil {
		fmt.Println("Error reading the image file:", err)
		return ""
	}

	// Encode the image data to Base64
	base64Encoded := base64.StdEncoding.EncodeToString(imageData)

	// Print the Base64 representation
	fmt.Println(base64Encoded)
	return base64Encoded
}
Editor is loading...