gpt4 book ai didi

asp.net-mvc-2 - CreateIfNotExists 的命名空间是什么?

转载 作者:行者123 更新时间:2023-12-02 14:25:24 27 4
gpt4 key购买 nike

在我的应用程序中,我尝试将文档上传到 Azure blob 存储。代码是:

// Namespaces for Azure
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

public ActionResult GetPdf(HttpPostedFileBase document)
{
int pdfocument = Request.ContentLength;

var doctype=Request.ContentType;

byte[] pdf = new byte[pdfocument];
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Setting1"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("containername");
container.CreateIfNotExists();
var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
container.SetPermissions(permissions);
string uniqueBlobName = "blobname";
CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
blob.Properties.ContentType = doctype;
blob.UploadByteArray(pdf);
}

当我构建应用程序时,我在 container.CreateIfNotExists() 处收到错误。错误是:

'Microsoft.WindowsAzure.StorageClient.CloudBlobContainer' does not contain a definition for 'CreateIfNotExists' and no extension method 'CreateIfNotExists' accepting a first argument of type 'Microsoft.WindowsAzure.StorageClient.CloudBlobContainer' could be found (are you missing a using directive or an assembly reference?)'.

我可以为该错误添加哪个命名空间?

最佳答案

CreateIfNotExists 是 Azure 库 2.0 版的一部分。

如果您使用 1.7 版 StorageClient 命名空间,则需要调用 CreateIfNotExist(无复数)

关于asp.net-mvc-2 - CreateIfNotExists 的命名空间是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14934325/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com