У меня есть этот код:
CloudBlob blob = _container.GetBlobReference(relativefilePath);
blob.Properties.ContentType = contentType;
blob.UploadFromStream(fileContent);
Когда я загружаю большой файл (150 МБ) в хранилище разработки, я получаю следующее исключение:
Microsoft.WindowsAzure.StorageClient.StorageClientException не было обработано кодом пользователя
Сообщение = Указанный большой двоичный объект уже существует.
Source=Microsoft.WindowsAzure.StorageClient
But it's not true, the file doesn't exist. Actually, I don't know why that should be a problem, every time I've tried, I can overwrite an existing blob w/o any problem. The most amazing is that when the exception appears in VS, I select "Enable editing", I move the execution cursor (the yellow arrow) to the 2nd line of code showed, execute... and then IT WORKS!!
I get the exception only with large files, and I don't understand why.
This is the exception detail:
Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled by user code
Message=The specified blob already exists.
Source=Microsoft.WindowsAzure.StorageClient
StackTrace:
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImpl(Func`1 impl)
at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source, BlobRequestOptions options)
at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source)
at AzureBlobOperations.AzureFileContainerOperations.PutFile(String relativefilePath, Stream fileContent, String contentType, Boolean createIfNotExists) in C:\Users\valeriano.tortola\Documents\Visual Studio 2010\Projects\TestWithBlobs\AzureBlobOperations\AzureFileOperations.cs:line 61
at TestWithBlobs.Web.Controllers.HomeController.PostFile(HttpPostedFileBase fileUpload) in C:\Users\valeriano.tortola\Documents\Visual Studio 2010\Projects\TestWithBlobs\TestWithBlobs.Web\Controllers\HomeController.cs:line 31
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException: System.Net.WebException
Message=The remote server returned an error: (409) Conflict.
Source=System
StackTrace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender)
InnerException: