随着Azure存储V10 SDK,斑点可以使用上传BlockBlobURL
作为在Node.js的指示快速开始:
const {
Aborter,
BlockBlobURL,
ContainerURL,
ServiceURL,
SharedKeyCredential,
StorageURL,
uploadFileToBlockBlob
} = require("@azure/storage-blob");
const containerName = "demo";
const blobName = "quickstart.txt";
const content = "hello!";
const credentials = new SharedKeyCredential(
STORAGE_ACCOUNT_NAME,
ACCOUNT_ACCESS_KEY
);
const pipeline = StorageURL.newPipeline(credentials);
const serviceURL = new ServiceURL(
`https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net`,
pipeline
);
const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);
const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName);
const aborter = Aborter.timeout(30 * ONE_MINUTE);
await blockBlobURL.upload(aborter, content, content.length);
然后可以使用以下setHTTPHeaders
方法设置内容类型:
await blockBlobURL.setHTTPHeaders(aborter, { blobContentType: "text/plain" });
文件可以通过上传uploadFileToBlockBlob
从方法@azure/storage-blob
。