MCPcopy Create free account
hub / github.com/027xiguapi/code-box / downloadImageAsBase64

Function downloadImageAsBase64

utils/chat-integration.ts:114–129  ·  view source on GitHub ↗
(imageUrl: string)

Source from the content-addressed store, hash-verified

112 * @param imageUrl 图片 URL
113 */
114export async function downloadImageAsBase64(imageUrl: string): Promise<string> {
115 try {
116 const response = await fetch(imageUrl)
117 const blob = await response.blob()
118
119 return new Promise((resolve, reject) => {
120 const reader = new FileReader()
121 reader.onloadend = () => resolve(reader.result as string)
122 reader.onerror = reject
123 reader.readAsDataURL(blob)
124 })
125 } catch (error) {
126 console.error("[Chat Integration] Download image error:", error)
127 throw error
128 }
129}
130
131/**
132 * 检测页面中的代码块并添加"解释代码"按钮

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected