【发布时间】:2016-03-05 01:51:03
【问题描述】:
有一些关于通过 ASP.NET MVC 将文件上传到 Azure 的参考,但我在 ASP.NET 网页字段中找不到任何参考
如何实现这样的代码上传到 Azure 存储?
嗯.. 欲了解更多信息,
我的目标是在 CK Editor 中上传图片
但由于 Azure 托管,普通的 CKEditor 参考不起作用。
所以我用谷歌搜索并使用了这个代码块
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("lawimage");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(name))
{
blockBlob.UploadFromStream(fileStream);
}
但它不起作用,
我的“web.config”是
<appSettings>
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=lawcbt;AccountKey=[MyAccountKey]/>
</appSettings>
有没有人通过 ASP.NET 网页上传到 Azure 存储?
P.S>为了更清楚,我的'upload.aspx'源文件是这个
【问题讨论】:
-
您是否遇到某种处理错误?还是对服务器的 POST 请求返回 OK (200) 但文件不在容器上?
-
处理错误,我想要一些完整的上传到 Azure 源代码是由 Asp.net 网页编写的
标签: asp.net azure ckeditor asp.net-webpages