简体   繁体   中英

downloading from blob works locally but not after publishing

Im creating a website which can b used to upload files to cloud and downloading the same. When i try to download the file when it is running locally everything works fine. After publishing the file to Azure the status shows that the file is downloaded but the file is not available in the download location. Thanks in Advance

//My Download Code
` protected void OnDownloadImage(object sender, CommandEventArgs e)
  {
     var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
     var client = account.CreateCloudBlobClient();
     CloudBlobContainer blobContainer = client.GetContainerReference("Gallery");
     var blobUri = (string)e.CommandArgument;
     var srcBlob = this.GetContainer().GetBlobReference(blobUri);
     srcBlob.FetchAttributes(new BlobRequestOptions { BlobListingDetails = BlobListingDetails.Metadata });
     var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
     path = path + @"\AJStorage";
     Directory.CreateDirectory(path);
     path = path + "\\" + Path.GetFileName(srcBlob.Metadata["FileName"]);
     srcBlob.DownloadToFile(path);
     this.status.Text = "File Download Successful. File Location : " + path;
   }`

I think I understand the issue. You are trying to download the file to the desktop - but that will be the desktop of the web server (where you will almost certainly not have permission) and not the desktop of the user (which is probably what you were after). If it is, you can't do that directly. Instead try sending the file to the HTTP Response stream. (I use DownloadToStream which is part of Microsoft.WindowsAzure.StorageClient)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM