How Upload PNG Image To IPFS

Hello mates, I am trying to upload a PNG image to IPFS running a daemon on my machine. The code below give a CID/hash but when I try to see it using the image do not appear. Comparing to JS codes, I am not passing any metadata, which is maybe the issue I guess.

I open the image, decode it, convert to bytes and then upload to IPFS using the import shell "" Anyone could help me?


func ReadImageBytes(path_image string) []byte {
	inputFile, _ := os.Open(path_image)


	File, err := os.Open(path_image)
	if err != nil {
	defer File.Close()

	img, err := png.Decode(File)
	if err != nil {

	sz := img.Bounds()
	raw := make([]uint8, (sz.Max.X-sz.Min.X)*(sz.Max.Y-sz.Min.Y)*4)
	idx := 0
	for y := sz.Min.Y; y < sz.Max.Y; y++ {
		for x := sz.Min.X; x < sz.Max.X; x++ {
			r, g, b, a := img.At(x, y).RGBA()
			raw[idx], raw[idx+1], raw[idx+2], raw[idx+3] = uint8(r), uint8(g), uint8(b), uint8(a)
			idx += 4
	return raw

func UploadIPFS(data []byte) (string, error) {

    sh := shell.NewShell("localhost:5001")

    reader := bytes.NewReader(data)

    fileHash, err := sh.Add(reader)

    if err != nil {

        return "", err


    return fileHash, nil