From 447b091f12298e925995cfaafe5e7a4ab6f0d31e Mon Sep 17 00:00:00 2001 From: slandymani Date: Wed, 2 Oct 2024 14:30:09 +0300 Subject: [PATCH] encode img before uploading to ipfs --- kvasir/execute.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kvasir/execute.go b/kvasir/execute.go index 705c7410..6989ca20 100644 --- a/kvasir/execute.go +++ b/kvasir/execute.go @@ -250,14 +250,6 @@ func uploadToIPFS(c *Context, l *Logger, file []byte, report ReportMsgWithKey) ( os.Remove(string(file)) }() - // Connect to local IPFS node - sh := shell.NewShell(c.ipfs) - // Upload the image to IPFS - pngCID, err := sh.Add(pngFile, shell.Pin(true)) - if err != nil { - return "", err - } - img, err := png.Decode(pngFile) if err != nil { return "", err @@ -283,6 +275,14 @@ func uploadToIPFS(c *Context, l *Logger, file []byte, report ReportMsgWithKey) ( return "", err } + // Connect to local IPFS node + sh := shell.NewShell(c.ipfs) + // Upload the image to IPFS + pngCID, err := sh.Add(pngFile, shell.Pin(true)) + if err != nil { + return "", err + } + jpgCID, err := sh.Add(jpgFile, shell.Pin(true)) if err != nil { return "", err