(key: string, customConfig?: BlobConfig)
| 623 | } |
| 624 | |
| 625 | async function getBlockBlobClientFor(key: string, customConfig?: BlobConfig) { |
| 626 | const { BlobServiceClient, StorageSharedKeyCredential } = await import('@azure/storage-blob') |
| 627 | let blobServiceClient: BlobServiceClientType |
| 628 | let containerName: string |
| 629 | |
| 630 | if (customConfig) { |
| 631 | if (customConfig.connectionString) { |
| 632 | blobServiceClient = BlobServiceClient.fromConnectionString(customConfig.connectionString) |
| 633 | } else if (customConfig.accountName && customConfig.accountKey) { |
| 634 | const credential = new StorageSharedKeyCredential( |
| 635 | customConfig.accountName, |
| 636 | customConfig.accountKey |
| 637 | ) |
| 638 | blobServiceClient = new BlobServiceClient( |
| 639 | `https://${customConfig.accountName}.blob.core.windows.net`, |
| 640 | credential |
| 641 | ) |
| 642 | } else { |
| 643 | throw new Error('Invalid custom blob configuration') |
| 644 | } |
| 645 | containerName = customConfig.containerName |
| 646 | } else { |
| 647 | blobServiceClient = await getBlobServiceClient() |
| 648 | containerName = BLOB_CONFIG.containerName |
| 649 | } |
| 650 | |
| 651 | return blobServiceClient.getContainerClient(containerName).getBlockBlobClient(key) |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Stage a single block from the server (body in hand), returning its |
no test coverage detected