Untitled

mail@pastecode.io avatar
unknown
golang
a year ago
382 B
1
Indexable
Never
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
}