none
empty image from blob storage

    Question

  • This is how I try to upload an image to Azure blog storage, then upload an empty file located there.

    I try to upload this image here:

    CloudStorageAccount storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(Accountname, KeyValue), true);
                // Create the blob client.
                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
                // Retrieve a reference to a container.
                CloudBlobContainer container = blobClient.GetContainerReference(ContainerValue);
    
                CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);
                using (var f = System.IO.File.Open(model.FileToUpload.FileName, FileMode.Create))
                {
                    await blockBlob.UploadFromStreamAsync(f);
                }

    But if i try to open this image say this.

    From danish to english: We can not open this file

    Wednesday, February 7, 2018 8:47 PM

Answers

All replies

  • Was this ever working before or have you always had this issue? 

    What documentation are you following? 

    We have some documentation that I have tested and confirmed it works on uploading/ downloading from blob storage. Most recently I used the PowerShell commands to quickly move files.  

    Transfer Objects to/from Azure Blob Storage 

    The above link is for PowerShell but if you look to the left you will see other options as well: 

    Wednesday, February 7, 2018 9:02 PM
    Moderator
  • There are several who tell me that the error lies when I try to upload. So here.

    using (var f = System.IO.File.OpenRead(fValue))
                    {
                        await blockBlob.UploadFromStreamAsync(f);
                    }

    but i get the error: FileNotFoundException

    Friday, February 9, 2018 4:26 PM
  • Jesper I don't have enough information to advise here. 

    Have you reviewed the docs I provided? 

    Is there a doc you are currently following? Can you share? 

    Friday, February 9, 2018 5:45 PM
    Moderator
  • Hello peter.sen, 

    Without knowning more details, I believe that you might need to use the UploadFromFile or UploadFromFileAsync method.

    ex: 

    string filepath ="..\.\somepath";

    blockBlob.UploadFromFile(filepath,Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null);


    • Edited by chrkdek Friday, February 9, 2018 11:04 PM edit
    Friday, February 9, 2018 11:03 PM
  • Errro with: Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null

    in my Controller have i Asyns Task<IActionResult>

    Saturday, February 10, 2018 8:32 PM
  • i have check now .... its error not coming but the image are empty...
    Saturday, February 10, 2018 9:05 PM
  • https://stackoverflow.com/questions/48725659/picture-is-blank-if-i-try-to-download-it-from-blob-storage
    Sunday, February 11, 2018 12:46 AM
  • Friday, February 16, 2018 8:25 PM
    Moderator