MCPcopy Create free account
hub / github.com/github/gh-aw / decodeBase64FileContent

Function decodeBase64FileContent

pkg/cli/download_workflow.go:197–206  ·  view source on GitHub ↗

decodeBase64FileContent decodes base64-encoded file content returned by the GitHub API. The GitHub API wraps lines at 60 characters and may include surrounding whitespace, so both are stripped before decoding.

(raw string)

Source from the content-addressed store, hash-verified

195// The GitHub API wraps lines at 60 characters and may include surrounding whitespace,
196// so both are stripped before decoding.
197func decodeBase64FileContent(raw string) ([]byte, error) {
198 cleaned := strings.ReplaceAll(strings.TrimSpace(raw), "\n", "")
199 content, err := base64.StdEncoding.DecodeString(cleaned)
200 if err != nil {
201 downloadLog.Printf("Base64 decode failed: cleaned_len=%d, err=%v", len(cleaned), err)
202 return nil, fmt.Errorf("failed to decode file content: %w", err)
203 }
204 downloadLog.Printf("Decoded base64 file content: bytes=%d", len(content))
205 return content, nil
206}

Callers 2

downloadWorkflowContentFunction · 0.85

Calls 2

PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by 1