Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用React将映像上载到Azure Blob存储_Reactjs_Azure Blob Storage - Fatal编程技术网

Reactjs 使用React将映像上载到Azure Blob存储

Reactjs 使用React将映像上载到Azure Blob存储,reactjs,azure-blob-storage,Reactjs,Azure Blob Storage,我想使用React将图像上载到Azure Blob存储 我试过很多例子,但都不管用 看起来最好的一个是,但仍然没有设法让它在React上工作 我现在尝试的是使用createContainerIfNotExists方法只是为了测试,错误是无法读取属性createBlobservicewithas of undefined 我的代码如下: import AzureStorage from 'azure-storage'; const account = { name: 'x', sas:

我想使用React将图像上载到Azure Blob存储

我试过很多例子,但都不管用

看起来最好的一个是,但仍然没有设法让它在React上工作

我现在尝试的是使用createContainerIfNotExists方法只是为了测试,错误是
无法读取属性createBlobservicewithas of undefined

我的代码如下:

import AzureStorage from 'azure-storage';

const account = {
  name: 'x',
  sas: 'x',
};

const blobUri = `https://${account.name}.blob.core.windows.net`;
const blobService = AzureStorage.Blob.createBlobServiceWithSas(blobUri, account.sas);

export const createContainer = () => {
  blobService.createContainerIfNotExists('test', (error, container) => {
    if (error) {
      // Handle create container error
    } else {
      console.log(container.name);
    }
  });
};

export default createContainer;

根据我的研究,因为您开发了React应用程序,所以我们不能使用
createBlockBlobFromBrowserFile
方法。我们可以在浏览器中使用该方法。有关更多详细信息,请参阅。


根据这种情况,我建议您使用另一种方法(例如
uploadStreamToBlockBlob
)使用V10SDK上传图像。有关更多详细信息,请参阅

能否告诉我您的错误消息?此外,能否提供您的测试代码?@JimXu编辑了这篇文章以显示我的实际代码您是否在html页面中添加了
?根据我的研究,仅支持使用经典的单一JS捆绑文件的浏览器使用。因此,您需要参考js文件。如果您仍然使用sdk,我建议您使用Azure storage sdk v10。有关更多详细信息,请参阅和。