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

Function getOrCreateBlobUrl

apps/sim/lib/pptx-renderer/utils/media.ts:53–67  ·  view source on GitHub ↗
(
  mediaPath: string,
  data: Uint8Array | ArrayBuffer,
  cache: Map<string, string>
)

Source from the content-addressed store, hash-verified

51 * @returns The blob URL string
52 */
53export function getOrCreateBlobUrl(
54 mediaPath: string,
55 data: Uint8Array | ArrayBuffer,
56 cache: Map<string, string>
57): string {
58 let url = cache.get(mediaPath)
59 if (!url) {
60 const mime = getMimeType(mediaPath)
61 const blobPart = data instanceof ArrayBuffer ? data : copyToArrayBuffer(data)
62 const blob = new Blob([blobPart], { type: mime })
63 url = URL.createObjectURL(blob)
64 cache.set(mediaPath, url)
65 }
66 return url
67}
68
69function copyToArrayBuffer(data: Uint8Array): ArrayBuffer {
70 const copy = new Uint8Array(data.byteLength)

Callers 6

resolveShapeBlipUrlFunction · 0.90
renderImageFunction · 0.90
renderVideoFunction · 0.90
renderAudioFunction · 0.90
resolveMediaUrlFunction · 0.90
renderBlipBackgroundFunction · 0.90

Calls 4

copyToArrayBufferFunction · 0.85
getMimeTypeFunction · 0.70
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected