繁体   English   中英

Azure Blob存储使电子应用程序崩溃

[英]Azure Blob Storage crashes electron app

当我将电子应用程序中的图片发布到Blob存储时,有时可以正常使用,而有时我在终端上收到此错误:

在此处输入图片说明

当我第一次使用此应用程序时,直到一个星期前,这个问题才出现。 发生时未对应用程序的此部分进行任何更改。 关于可能导致它的任何想法。

电子应用程序变白,开发工具断开连接。

这是代码:

 var azure = require('azure-storage'); var blobSvc = azure.createBlobService('*connection keys inside here*'); function createBlob() { blobSvc.createContainerIfNotExists('photos', {publicAccessLevel : 'blob'}, function(error, result, response){ if(!error){ console.log(response); } }); console.log("creating image for student#: " + stud_id); blobSvc.createBlockBlobFromStream('photos', stud_id + '.jpg', toStream(imgData), imgData.size, function(error, result, response){ if(!error){ console.log("file upload: \\n" + JSON.stringify(result) + " \\n" + JSON.stringify(response)); createPerson(); } else if (error) { console.log("error: " + JSON.stringify(error)); } }); } 

在您的代码中,实际上可能立即调用了createBlockBlobFromStream ,可能没有创建容器。 这可能会导致问题。

因此,您需要将它们放在createContainerIfNotExists函数的回调中:

blobSvc.createContainerIfNotExists('photos', {publicAccessLevel : 'blob'}, function(error, result, response) {
  if(!error) {
    console.log(response);

    console.log("creating image for student#: " + stud_id);
    blobSvc.createBlockBlobFromStream('photos', stud_id + '.jpg', toStream(imgData), imgData.size, function(error, result, response) {
      if(!error) {
        console.log("file upload: \n" + JSON.stringify(result) + " \n" + JSON.stringify(response));
        createPerson();

      } else {
        console.log("error: " + JSON.stringify(error));
      }
    });
  }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM