我正在尝试使用Azure Blob存储来存储Blob,但是大部分时间我都会从Blob存储中获得“请求中止”响应。我在Express API中使用Node.js v10 SDK,并且感觉到它与我配置服务的方式有关。
我正在使用Azurite模仿Azure存储服务。
在我的app.js中,我configureBlobStore()在启动时运行函数:
export const configureBlobStore = async containerName => {
const sharedKeyCredential = new SharedKeyCredential(
process.env.AZURE_STORAGE_ACCOUNT_NAME,
process.env.AZURE_STORAGE_ACCOUNT_ACCESS_KEY,
);
const pipeline = StorageURL.newPipeline(sharedKeyCredential);
serviceUrl = new ServiceURL('http://blob:10000/devstoreaccount1', pipeline);
if (!containerUrl) {
containerUrl = ContainerURL.fromServiceURL(serviceUrl, containerName);
try {
await containerUrl.create(aborter);
} catch (err) {
console.log(err);
console.log('Container already existed, skipping creation');
}
}
return containerUrl;
};
Run Code Online (Sandbox Code Playgroud)
然后保存斑点,我运行我的函数 saveToBlobStore()
let { originalname: blobName } = file;
const blockBlobUrl = BlockBlobURL.fromContainerURL(containerUrl, blobName);
const uploadOptions = { bufferSize: 4 …Run Code Online (Sandbox Code Playgroud)