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

Function getMultipartPartUrls

apps/sim/lib/uploads/providers/blob/client.ts:553–623  ·  view source on GitHub ↗
(
  key: string,
  partNumbers: number[],
  customConfig?: BlobConfig
)

Source from the content-addressed store, hash-verified

551 * Generate presigned URLs for uploading parts
552 */
553export async function getMultipartPartUrls(
554 key: string,
555 partNumbers: number[],
556 customConfig?: BlobConfig
557): Promise<AzurePartUploadUrl[]> {
558 const {
559 BlobServiceClient,
560 BlobSASPermissions,
561 generateBlobSASQueryParameters,
562 StorageSharedKeyCredential,
563 } = await import('@azure/storage-blob')
564 let blobServiceClient: BlobServiceClientType
565 let containerName: string
566 let accountName: string
567 let accountKey: string
568
569 if (customConfig) {
570 if (customConfig.connectionString) {
571 blobServiceClient = BlobServiceClient.fromConnectionString(customConfig.connectionString)
572 const credentials = parseConnectionString(customConfig.connectionString)
573 accountName = credentials.accountName
574 accountKey = credentials.accountKey
575 } else if (customConfig.accountName && customConfig.accountKey) {
576 const credential = new StorageSharedKeyCredential(
577 customConfig.accountName,
578 customConfig.accountKey
579 )
580 blobServiceClient = new BlobServiceClient(
581 `https://${customConfig.accountName}.blob.core.windows.net`,
582 credential
583 )
584 accountName = customConfig.accountName
585 accountKey = customConfig.accountKey
586 } else {
587 throw new Error('Invalid custom blob configuration')
588 }
589 containerName = customConfig.containerName
590 } else {
591 blobServiceClient = await getBlobServiceClient()
592 containerName = BLOB_CONFIG.containerName
593 const credentials = getAccountCredentials()
594 accountName = credentials.accountName
595 accountKey = credentials.accountKey
596 }
597
598 const containerClient = blobServiceClient.getContainerClient(containerName)
599 const blockBlobClient = containerClient.getBlockBlobClient(key)
600
601 return partNumbers.map((partNumber) => {
602 const blockId = deriveBlobBlockId(partNumber)
603
604 const sasOptions = {
605 containerName,
606 blobName: key,
607 permissions: BlobSASPermissions.parse('w'), // Write permission
608 startsOn: new Date(),
609 expiresOn: new Date(Date.now() + 3600 * 1000), // 1 hour
610 }

Callers 1

route.tsFile · 0.85

Calls 6

parseConnectionStringFunction · 0.85
getBlobServiceClientFunction · 0.85
getAccountCredentialsFunction · 0.85
deriveBlobBlockIdFunction · 0.85
parseMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected