none
A doubt using Rest API for windows azure storage (Delimiter)

    Question

  • Hi,

    I have a container with blobs and a folder containing blog. Now If I use this URI, http://myaccount.blob.core.windows.net/mycontainer?restype=container&comp=list&delimiter=/

    I was expecting the output to have all the blob names under the container and the folder name alone. But to my surprise all I got is blob names. Can someone please tell me whether there is anything wrong, or should I change the query ? Thanks in advance.

    Friday, August 06, 2010 8:07 PM

Answers

  • Hi,

    URL for listing blobs that you're using looks fine. Here is one thing that you may want to look into the response received from Azure Storage.

    You will not get a separate node for folders i.e. all folders and blobs are contained "Blobs" node. The way to differentiate between a folder & a blob is by looking for <BlobPrefix> node in the response XML. This will contain the folders while the <Blob> node will contain the actual blob.

    For more information, please check this link: http://msdn.microsoft.com/en-us/library/dd135734.aspx .

    <?xml version="1.0" encoding="utf-8"?><br/>
    <EnumerationResults ContainerName="http://myaccount.blob.core.windows.net/mycontainer"><br/>
     <Prefix>string-value</Prefix><br/>
     <Marker>string-value</Marker><br/>
     <MaxResults>int-value</MaxResults><br/>
     <Delimiter>string-value</Delimiter><br/>
     <Blobs><br/>
      <Blob><strong><br/>
    </strong>
       <Name>blob-name</name><br/>
       <Snapshot>date-time-value</Snapshot><br/>
       <Url>blob-address</Url><br/>
       <Properties><br/>
        <Last-Modified>date-time-value</Last-Modified><br/>
        <Etag>etag</Etag><br/>
        <Content-Length>size-in-bytes</Content-Length><br/>
        <Content-Type>blob-content-type</Content-Type><br/>
        <Content-Encoding /><br/>
        <Content-Language /><br/>
        <Content-MD5 /><br/>
        <Cache-Control /><br/>
        <x-ms-blob-sequence-number>sequence-number</x-ms-blob-sequence-number><br/>
        <BlobType>BlockBlob|PageBlob</BlobType><br/>
        <LeaseStatus>locked|unlocked</LeaseStatus><br/>
       </Properties><br/>
       <Metadata>  <br/>
        <Name>value</Name><br/>
       </Metadata><br/>
      </Blob><br/>
      <BlobPrefix><br/>
       <Name>blob-prefix</Name><br/>
      </BlobPrefix><br/>
     </Blobs><br/>
     <NextMarker /><br/>
    </EnumerationResults><br/>
    
    

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

    • Marked as answer by Mog Liang Friday, August 13, 2010 6:20 AM
    Saturday, August 07, 2010 6:15 AM

All replies

  • Your expectation would seem realistic given the documentation.  It might be worth using some third-party storage visualization tool such as Cloud Storage Studio to verify the "folder" structure is what you think it is.

    Saturday, August 07, 2010 12:21 AM
    Answerer
  • Can you share some of the code you're using and what the response looks like?

    • Edited by Steve Marx Saturday, August 07, 2010 12:37 AM misread Neil's reply
    Saturday, August 07, 2010 12:33 AM
  • Hi,

    URL for listing blobs that you're using looks fine. Here is one thing that you may want to look into the response received from Azure Storage.

    You will not get a separate node for folders i.e. all folders and blobs are contained "Blobs" node. The way to differentiate between a folder & a blob is by looking for <BlobPrefix> node in the response XML. This will contain the folders while the <Blob> node will contain the actual blob.

    For more information, please check this link: http://msdn.microsoft.com/en-us/library/dd135734.aspx .

    <?xml version="1.0" encoding="utf-8"?><br/>
    <EnumerationResults ContainerName="http://myaccount.blob.core.windows.net/mycontainer"><br/>
     <Prefix>string-value</Prefix><br/>
     <Marker>string-value</Marker><br/>
     <MaxResults>int-value</MaxResults><br/>
     <Delimiter>string-value</Delimiter><br/>
     <Blobs><br/>
      <Blob><strong><br/>
    </strong>
       <Name>blob-name</name><br/>
       <Snapshot>date-time-value</Snapshot><br/>
       <Url>blob-address</Url><br/>
       <Properties><br/>
        <Last-Modified>date-time-value</Last-Modified><br/>
        <Etag>etag</Etag><br/>
        <Content-Length>size-in-bytes</Content-Length><br/>
        <Content-Type>blob-content-type</Content-Type><br/>
        <Content-Encoding /><br/>
        <Content-Language /><br/>
        <Content-MD5 /><br/>
        <Cache-Control /><br/>
        <x-ms-blob-sequence-number>sequence-number</x-ms-blob-sequence-number><br/>
        <BlobType>BlockBlob|PageBlob</BlobType><br/>
        <LeaseStatus>locked|unlocked</LeaseStatus><br/>
       </Properties><br/>
       <Metadata>  <br/>
        <Name>value</Name><br/>
       </Metadata><br/>
      </Blob><br/>
      <BlobPrefix><br/>
       <Name>blob-prefix</Name><br/>
      </BlobPrefix><br/>
     </Blobs><br/>
     <NextMarker /><br/>
    </EnumerationResults><br/>
    
    

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

    • Marked as answer by Mog Liang Friday, August 13, 2010 6:20 AM
    Saturday, August 07, 2010 6:15 AM