locked
How to decode BLOB files after downloading RRS feed

  • Question

  • I am trying to decode files after download via  Azure Storage SDK for Java. 

    Here is my code:

    <style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Monaco; color: #931a68} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Monaco} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Monaco; color: #4e9072} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Monaco; min-height: 25.0px} span.s1 {color: #000000} span.s2 {color: #7e504f} span.s3 {color: #3933ff} span.s4 {color: #931a68} span.s5 {color: #0326cc} span.Apple-tab-span {white-space:pre} </style>

    try
    		{
    		    CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
    		    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
    		    CloudBlobContainer container = blobClient.getContainerReference("mycontainer");
    		    CloudBlobDirectory blobDirectory = container.getDirectoryReference("shi");
    		    for (ListBlobItem blobItem : blobDirectory.listBlobs()) {
    		        if (blobItem instanceof CloudBlob) {
    		            CloudBlob blob = (CloudBlob) blobItem;
    		            blob.download(new FileOutputStream("/Users/shi/Downloads/" + blob.getName()));
    		        }
    		    }
    		}

    This code downloads all the BLOB files from mycontainer but there are encoded. How can I download them but in decoded form.

    When you see the file with text editor, you see some ascii codes like: õ∂πñsÎÅ”·ñÇYt‹.... There were not in the file before sending file to Azure Storage



    Wednesday, November 15, 2017 10:26 AM

All replies

  • Hi,

    are you sure the "problem" is caused by the download? Did you try to download the blob directly from the Azure Portal (or storage explorer) and check what's inside the file once downloaded?

    Basically, are you uploading the blob and setting the correct content type?


    Floris van der Ploeg - www.florisvanderploeg.com

    If my post was helpfull, remember to click the "Propose as answer" button.

    Wednesday, November 15, 2017 1:14 PM

  • my colleague uses Azure SDK and AVRO to save the files in Azure Storage. Before saving, the file are in json format, but when I use the above code or download manually them from Azure, they are encoded.
    Wednesday, November 15, 2017 1:47 PM
  • Can you check the content type using Storage Explorer (https://azure.microsoft.com/en-in/features/storage-explorer/)?

    It should be text/plain or application/json:

    Storage Explorer Content Type


    Floris van der Ploeg - www.florisvanderploeg.com

    If my post was helpfull, remember to click the "Propose as answer" button.

    Wednesday, November 15, 2017 2:18 PM
  • I used it. no difference
    Wednesday, November 15, 2017 2:59 PM
  • Ok, but what is the content type of the file you're downloading? It's displayed in Storage Explorer.

    Floris van der Ploeg - www.florisvanderploeg.com

    If my post was helpfull, remember to click the "Propose as answer" button.

    Wednesday, November 15, 2017 3:02 PM
  • Block Blob
    Wednesday, November 15, 2017 3:33 PM
  • Not the Blob Type, but the Content Type. The content type is not visible in the Azure Portal, you'll need to use something like storage explorer for this (use the link I provided in a previous post).


    Floris van der Ploeg - www.florisvanderploeg.com

    If my post was helpfull, remember to click the "Propose as answer" button.

    • Proposed as answer by vikranth s Monday, November 27, 2017 8:15 PM
    Wednesday, November 15, 2017 3:49 PM