Files
toolkit/packages/cache/src/internal/blob/upload-cache.ts
T

27 lines
949 B
TypeScript
Raw Normal View History

2024-06-13 03:16:59 -07:00
import * as core from '@actions/core'
import {
2024-09-24 03:17:44 -07:00
BlobClient,
BlockBlobClient,
2024-06-13 03:16:59 -07:00
BlockBlobParallelUploadOptions
} from '@azure/storage-blob'
export async function UploadCacheFile(
signedUploadURL: string,
2024-06-13 03:16:59 -07:00
archivePath: string,
): Promise<{}> {
// TODO: tighten the configuration and pass the appropriate user-agent
2024-06-13 03:16:59 -07:00
// Specify data transfer options
const uploadOptions: BlockBlobParallelUploadOptions = {
blockSize: 4 * 1024 * 1024, // 4 MiB max block size
concurrency: 4, // maximum number of parallel transfer workers
2024-06-13 03:16:59 -07:00
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
const blobClient: BlobClient = new BlobClient(signedUploadURL)
2024-06-13 03:16:59 -07:00
const blockBlobClient: BlockBlobClient = blobClient.getBlockBlobClient()
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`)
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`)
2024-06-13 03:16:59 -07:00
return blockBlobClient.uploadFile(archivePath, uploadOptions);
}