在我的应用程序中,我试图将文档上传到 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' 不包含'CreateIfNotExists' 的定义,并且找不到接受类型为'Microsoft.WindowsAzure.StorageClient.CloudBlobContainer' 的第一个参数的扩展方法'CreateIfNotExists'(您是否缺少 using 指令还是程序集参考?)'。
我可以为该错误添加哪个命名空间?