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

Function buildObjectFallbackUrl

apps/sim/lib/uploads/providers/s3/client.ts:442–457  ·  view source on GitHub ↗

* Build a fallback object URL for when the SDK omits `Location` on multipart * completion. For a custom `S3_CONFIG.endpoint` it matches the configured * addressing mode — path-style for MinIO/Ceph (`forcePathStyle`), virtual-hosted * (bucket as a subdomain) for R2 and friends. Falls back to the A

(bucket: string, region: string, key: string)

Source from the content-addressed store, hash-verified

440 * keys containing spaces or reserved characters still yield a valid URL.
441 */
442function buildObjectFallbackUrl(bucket: string, region: string, key: string): string {
443 const encodedKey = key
444 .split('/')
445 .map((segment) => encodeURIComponent(segment))
446 .join('/')
447 if (S3_CONFIG.endpoint) {
448 const base = S3_CONFIG.endpoint.replace(/\/+$/, '')
449 if (S3_CONFIG.forcePathStyle) {
450 return `${base}/${bucket}/${encodedKey}`
451 }
452 const url = new URL(base)
453 url.hostname = `${bucket}.${url.hostname}`
454 return `${url.origin}/${encodedKey}`
455 }
456 return `https://${bucket}.s3.${region}.amazonaws.com/${encodedKey}`
457}
458
459/**
460 * Complete multipart upload for S3

Callers 1

Calls 2

joinMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected