mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-01 07:53:18 +08:00
Cleanups and package refactoring
This commit is contained in:
27
packages/cache/src/internal/blob/upload-cache.ts
vendored
Normal file
27
packages/cache/src/internal/blob/upload-cache.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as core from '@actions/core'
|
||||
import {
|
||||
BlobClient,
|
||||
BlockBlobClient,
|
||||
BlockBlobParallelUploadOptions
|
||||
} from '@azure/storage-blob'
|
||||
|
||||
export async function UploadCacheFile(
|
||||
signedUploadURL: string,
|
||||
archivePath: string,
|
||||
): Promise<{}> {
|
||||
// TODO: tighten the configuration and pass the appropriate user-agent
|
||||
// Specify data transfer options
|
||||
const uploadOptions: BlockBlobParallelUploadOptions = {
|
||||
blockSize: 4 * 1024 * 1024, // 4 MiB max block size
|
||||
concurrency: 4, // maximum number of parallel transfer workers
|
||||
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
|
||||
};
|
||||
|
||||
const blobClient: BlobClient = new BlobClient(signedUploadURL)
|
||||
const blockBlobClient: BlockBlobClient = blobClient.getBlockBlobClient()
|
||||
|
||||
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`)
|
||||
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`)
|
||||
|
||||
return blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
}
|
||||
Reference in New Issue
Block a user