MCPcopy Index your code
hub / github.com/simstudioai/sim / createFileContentFromBase64

Function createFileContentFromBase64

apps/sim/lib/uploads/utils/file-utils.ts:157–191  ·  view source on GitHub ↗
(
  base64: string,
  mimeType: string
)

Source from the content-addressed store, hash-verified

155 * Create message content from base64-encoded file data.
156 */
157export function createFileContentFromBase64(
158 base64: string,
159 mimeType: string
160): MessageContent | null {
161 // SVG is XML text — Claude only supports raster image formats (JPEG, PNG, GIF, WebP),
162 // so send SVGs as an XML document instead
163 if (mimeType.toLowerCase() === 'image/svg+xml') {
164 return {
165 type: 'document',
166 source: {
167 type: 'base64',
168 media_type: 'text/xml',
169 data: base64,
170 },
171 }
172 }
173
174 const contentType = getContentType(mimeType)
175 if (!contentType) {
176 return null
177 }
178
179 if (contentType === 'image' && !MODEL_SUPPORTED_IMAGE_MIME_TYPES.has(mimeType.toLowerCase())) {
180 return null
181 }
182
183 return {
184 type: contentType,
185 source: {
186 type: 'base64',
187 media_type: mimeType,
188 data: base64,
189 },
190 }
191}
192
193export const MODEL_SUPPORTED_IMAGE_MIME_TYPES = new Set([
194 'image/jpeg',

Callers 2

createFileContentFunction · 0.85

Calls 1

getContentTypeFunction · 0.70

Tested by

no test coverage detected