var BlobSerivceClient = require('@azure/storage-blob');
var multipart = require('parse-multipart');
const AZURE_STORAGE_CONNECTION_STRING = process.env["connectionstringstoragepath"]
module.exports = async function (context, req) {
context.log('Javascript HTTP trigger function processed a request '+multipart+" "+AZURE_STORAGE_CONNECTION_STRING+" "+blobSerivceClienttop);
var bodyBuffer = Buffer.from(req.body);
var boundary = multipart.getBoundary(req.headers['content-type']);
var parts = multipart.Parse(bodyBuffer, boundary);
const blobSerivceClient = await BlobSerivceClient.fromConnectionString(AZURE_STORAGE_CONNECTION_STRING);
const container = "bankfeedsdbfiles";
const containerClient = await blobSerivceClient.getContainerClient(container);
const blobName = parts[0].filename;
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadblobResponse = await blockBlobClient.upload(parts[0].data, parts[0].data.length);
context.res = {body: {name: parts[0].filename, type: parts[0].type, data: parts[0].data.length}};
context.done();
}
以上是我的代码,我收到如下错误:
2021-12-27T09:49:25.507 [错误] 执行“Functions.dbfilesupload”(失败,ID = fa953980-82b2-4c95-a13e-13988fd1c67e,持续时间 = 240 毫秒)结果:FailureException:TypeError:blobSerivceClienttop.fromConnectionString 不是函数堆栈: TypeError: blobSerivceClienttop.fromConnectionString is not a functionat module.exports (D:\home\site\wwwroot\dbfilesupload\index.js:13:58) at t.WorkerChannel.invocationRequest (D:\Program Files (x86)\SiteExtensions \Functions\4.0.1\workers\node\worker-bundle.js:2:16866) 在 c。(D:\Program Files (x86)\SiteExtensions\Functions\4.0.1\workers\node\worker-bundle.js:2:13767) 在 c.emit (events.js:400:28) 在 addChunk (internal/在 Object.onReceiveMessage (D :\Program Files (x86)\SiteExtensions\Functions\4.0.1\workers\node\worker-bundle.js:2:66126) 在 Object.onReceiveMessage (D:\Program Files (x86)\SiteExtensions\Functions\4.0.1 \workers\node\worker-bundle.js:2:58414) 位于 D:\Program Files (x86)\SiteExtensions\Functions\4.0.1\workers\node\worker-bundle.js:2:32555。我还为@azure/storage-blob 和 parse-multipart 安装了包