Impossible de télécharger vers Azure Blob Storage: le serveur distant a renvoyé une erreur: (400) Bad Request

Je suis en train de créer un utilitaire à télécharger le fichier à partir de l'internet et le télécharger à nouveau à Azure blob storage.
Blob conteneurs déjà créé bien; Mais pour une raison que je suis "400 Bad Request" exception quand j'ai essayé de télécharger le fichier pour le stockage ... nom du Conteneur est créé, petites lettres, de sorte que les caractères spéciaux. Mais je ne sais toujours pas pourquoi je me fais de l'exception!

S'il vous plaît aider.

Note:

  • Je ne suis pas en utilisant n'importe quel émulateur ... tester Directement sur le cloud.
  • Tous mes contenants "Public" Conteneur option d'accès.

Ici est l'exception:

An exception of type 'Microsoft.WindowsAzure.Storage.StorageException' 
occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code
Additional information: The remote server returned an error: (400) Bad Request.

Et voici le code:

foreach (var obj in objectsList)
{
     var containerName = obj.id.Replace("\"", "").Replace("_", "").Trim();
     CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);

     if (blobContainer.Exists())
     {
         var fileNamesArr = obj.fileNames.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);

         foreach (var sora in fileNamesArr)
         {
             int soraInt = int.Parse(sora.Replace("\"", ""));
             String fileName = String.Format("{0}.mp3", soraInt.ToString("000"));

             var url = String.Format("http://{0}/{1}/{2}", obj.hostName.Replace("\"", ""), obj.id.Replace("\"", ""), fileName.Replace("\"", "")).ToLower();

             var tempFileName = "temp.mp3";

             var downloadedFilePath = Path.Combine(Path.GetTempPath(), tempFileName).ToLower();

             var webUtil = new WebUtils(url);
             await webUtil.DownloadAsync(url, downloadedFilePath).ContinueWith(task =>
             {
                 var blobRef = blobContainer.GetBlockBlobReference(fileName.ToLower());
                 blobRef.Properties.ContentType = GetMimeType(downloadedFilePath);

                 using (var fs = new FileStream(downloadedFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                 {
                     blobRef.UploadFromStream(fs); //<--- Exception
                 }
             });
         }
      }
      else
      {
          throw new Exception(obj.id.Replace("\"", "") + " Container not exist!");
      }
}

Edit: Le Stockage De L'Exception

Microsoft.WindowsAzure.Le stockage.StorageException: Le serveur distant a retourné une erreur: (400) Bad Request. ---> Système.Net.WebException: Le serveur distant a retourné une erreur: (400) Bad Request.
au Système.Net.HttpWebRequest.GetRequestStream(TransportContext& le contexte)
au Système.Net.HttpWebRequest.GetRequestStream()
chez Microsoft.WindowsAzure.Le stockage.De base.Exécuteur testamentaire.Exécuteur testamentaire.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand
1 cmd, IRetryPolicy politique, OperationContext operationContext)
chez Microsoft.WindowsAzure.Le stockage.Blob.CloudBlockBlob.UploadFromStreamHelper(Stream source, les valeurs null`1 longueur, AccessCondition accessCondition, méthode blobrequestoptions options, OperationContext operationContext)
chez Microsoft.WindowsAzure.Le stockage.Blob.CloudBlockBlob.UploadFromStream(Stream source, AccessCondition accessCondition, méthode blobrequestoptions options, OperationContext operationContext)
au TelawatAzureUtility.StorageService.<>c__DisplayClass4.b__12(Tâche) dans \psf\Home\Documents\Visual Studio 14\Projets\Telawat Azure Utility\TelawatAzureUtility\StorageService.cs:la ligne 128
Demande D'Informations
Iddemande:
RequestDate:Sat, 28 Jun 2014 20:12:14 GMT
StatusMessage:Bad Request

Edit 2: Demande D'Informations:

Impossible de télécharger vers Azure Blob Storage: le serveur distant a renvoyé une erreur: (400) Bad Request

Impossible de télécharger vers Azure Blob Storage: le serveur distant a renvoyé une erreur: (400) Bad Request

Edit 3: Le problème vient de WebUtils .. je l'ai remplacé par ci-dessous de code et ça marche!!! Je vais ajouter weUtils code, peut-être vous pouvez aider à savoir quel est le problème avec lui.

HttpClient client = new HttpClient();
var stream = await client.GetStreamAsync(url);

WebUtils Code:

public class WebUtils
{
    private Lazy<IWebProxy> proxy;

    public WebUtils(String url)
    {
        proxy = new Lazy<IWebProxy>(() => string.IsNullOrEmpty(url) ? null : new WebProxy {
            Address = new Uri(url), UseDefaultCredentials = true });
    }

    public IWebProxy Proxy
    {
        get { return proxy.Value; }
    }

    public Task DownloadAsync(string requestUri, string filename)
    {
        if (requestUri == null)
            throw new ArgumentNullException("requestUri is missing!");

        return DownloadAsync(new Uri(requestUri), filename);
    }

    public async Task DownloadAsync(Uri requestUri, string filename)
    {
        if (filename == null)
            throw new ArgumentNullException("filename is missing!");

        if (Proxy != null)
        {
            WebRequest.DefaultWebProxy = Proxy;
        }

        using (var httpClient = new HttpClient())
        {
            using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
            {
                using (Stream contentStream = await (await httpClient.SendAsync(request)).Content.ReadAsStreamAsync())
                {
                    using (var stream = new FileStream(filename, FileMode.Create, FileAccess.Write))
                    {
                        contentStream.CopyTo(stream);
                        stream.Flush();
                        stream.Close();
                    }
                    contentStream.Close();
                }
            }
        }
    }
}

Aussi quand j'ai essayé ce code ... le 'Attente' ne finira jamais ou terminé!

webUtil.DownloadAsync(url, downloadedFilePath).Wait()

source d'informationauteur bunjeeb