(key: string, customConfig?: BlobConfig)
| 746 | * Abort multipart upload by deleting the blob if it exists |
| 747 | */ |
| 748 | export async function abortMultipartUpload(key: string, customConfig?: BlobConfig): Promise<void> { |
| 749 | const { BlobServiceClient, StorageSharedKeyCredential } = await import('@azure/storage-blob') |
| 750 | let blobServiceClient: BlobServiceClientType |
| 751 | let containerName: string |
| 752 | |
| 753 | if (customConfig) { |
| 754 | if (customConfig.connectionString) { |
| 755 | blobServiceClient = BlobServiceClient.fromConnectionString(customConfig.connectionString) |
| 756 | } else if (customConfig.accountName && customConfig.accountKey) { |
| 757 | const credential = new StorageSharedKeyCredential( |
| 758 | customConfig.accountName, |
| 759 | customConfig.accountKey |
| 760 | ) |
| 761 | blobServiceClient = new BlobServiceClient( |
| 762 | `https://${customConfig.accountName}.blob.core.windows.net`, |
| 763 | credential |
| 764 | ) |
| 765 | } else { |
| 766 | throw new Error('Invalid custom blob configuration') |
| 767 | } |
| 768 | containerName = customConfig.containerName |
| 769 | } else { |
| 770 | blobServiceClient = await getBlobServiceClient() |
| 771 | containerName = BLOB_CONFIG.containerName |
| 772 | } |
| 773 | |
| 774 | const containerClient = blobServiceClient.getContainerClient(containerName) |
| 775 | const blockBlobClient = containerClient.getBlockBlobClient(key) |
| 776 | |
| 777 | try { |
| 778 | await blockBlobClient.deleteIfExists() |
| 779 | } catch (error) { |
| 780 | logger.warn('Error cleaning up multipart upload:', error) |
| 781 | } |
| 782 | } |
no test coverage detected