Ce sujet n'a pas encore été évalué - Évaluez ce sujet

List Blobs

The List Blobs operation enumerates the list of blobs under the specified container.

The List Blobs request may be constructed as follows. Replace myaccount with the name of your storage account:

 

Method Request URI HTTP Version

GET

http://myaccount.blob.core.windows.net/mycontainer?restype=container&comp=list

HTTP/1.1

When making a request against the local storage service, specify the local hostname and Blob service port as 127.0.0.1:10000, followed by the local storage account name:

 

Method Request URI HTTP Version

GET

http://127.0.0.1:10000/devstoreaccount1/mycontainer?restype=container&comp=list

HTTP/1.1

For more information, see Vue d'ensemble de l'émulateur de stockage Windows Azure and Différences entre l'émulateur de stockage et les services de stockage Windows Azure.

The following additional parameters may be specified on the URI.

 

Parameter Description

prefix

Optional. Filters the results to return only blobs whose names begin with the specified prefix.

delimiter

Optional. When the request includes this parameter, the operation returns a BlobPrefix element in the response body that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter character. The delimiter may be a single character or a string.

marker

Optional. A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items.

The marker value is opaque to the client.

maxresults

Optional. Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not specify maxresults or specifies a value greater than 5,000, the server will return up to 5,000 items.

Setting maxresults to a value less than or equal to zero results in error response code 400 (Bad Request).

include={snapshots,metadata,uncommittedblobs}

Optional. Specifies that the response should include one or more of the following subsets:

  • snapshots: Specifies that snapshots should be included in the enumeration. Snapshots are listed from oldest to newest in the response.

  • metadata: Specifies that blob metadata be returned in the response.

  • uncommittedblobs: Specifies that blobs for which blocks have been uploaded, but which have not been committed using Put Block List, be included in the response.

If you specify more than one of these options on the URI, note that you must include a URL-encoded comma to separate them.

The following table describes required and optional request headers.

 

Request Header Description

Authorization

Required. Specifies the authentication scheme, account name, and signature. For more information, see Authentication Schemes.

Date or x-ms-date

Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authentication Schemes.

x-ms-version

Required for all authenticated requests, optional for anonymous requests. Specifies the version of the operation to use for this request. For more information, see Storage Services Versioning.

See Enumerating Blob Resources for a sample request.

The response includes an HTTP status code, a set of response headers, and a response body in XML format.

A successful operation returns status code 200 (OK).

For information about status codes, see Status and Error Codes.

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

 

Response header Description

Content-Type

Specifies the format in which the results are returned. Currently this value is application/xml.

x-ms-request-id

This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations.

x-ms-version

Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above.

This header is also returned for anonymous requests without a version specified if the container was marked for public access using the 2009-09-19 version of the Blob service.

Date

A UTC date/time value generated by the service that indicates the time at which the response was initiated.

The format of the XML response is as follows.

Note that the Prefix, Marker, MaxResults, and Delimiter elements are present only if they were specified on the request URI. The NextMarker element has a value only if the list results are not complete.

Snapshots, blob metadata, and uncommitted blobs are included in the response only if they are specified with the include parameter on the request URI.

In version 2009-09-19, the blob's properties are encapsulated within a Properties element.

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

noteRemarque
Beginning with version 2009-09-19, List Blobs returns the following renamed elements in the response body:

  • Last-Modified (previously LastModified)

  • Content-Length (previously Size)

  • Content-Type (previously ContentType)

  • Content-Encoding (previously ContentEncoding)

  • Content-Language (previously ContentLanguage)

The Content-MD5 element appears only if the blob was created with version 2009-09-19 or later.

See Enumerating Blob Resources for a sample response.

If the container's access control list (ACL) is set to allow anonymous access to the container, any client may call this operation. Otherwise, only the account owner can list the blobs within a container.

Blob Properties in the Response

If you have requested that uncommitted blobs be included in the enumeration, note that some properties are not set until the blob is committed, so some properties may not be returned in the response.

The x-ms-blob-sequence-number element is only returned for page blobs.

For page blobs, the value returned in the Content-Length element corresponds to the value of the blob's x-ms-blob-content-length header.

The Content-MD5 element appears in the response body only if it has been set on the blob using version 2009-09-19 or later. You can set the Content-MD5 property when the blob is created or by calling Set Blob Properties.

Metadata in the Response

The Metadata element is present only if the include=metadata parameter was specified on the URI. Within the Metadata element, the value of each name-value pair is listed within an element corresponding to the pair's name.

Note that metadata requested with this parameter must be stored in accordance with the naming restrictions imposed by the 2009-09-19 version of the Blob service. Beginning with this version, all metadata names must adhere to the naming conventions for C# identifiers.

If a metadata name-value pair violates the naming restrictions enforced by the 2009-09-19 version, the response body indicates the problematic name within an x-ms-invalid-name element, as shown in the following XML fragment:


      …
      <Metadata>
        <MyMetadata1>first value</MyMetadata1>
        <MyMetadata2>second value</MyMetadata2>
        <x-ms-invalid-name>invalid-metadata-name</x-ms-invalid-name>
      </Metadata>
      …

Snapshots in the Response

Snapshots are listed in the response only if the include=snapshots parameter was specified on the URI. Snapshots listed in the response do not include the LeaseStatus element, as snapshots cannot have active leases.

If you call List Blobs with a delimiter, you cannot also include snapshots in the enumeration. A request that includes both returns an InvalidQueryParameter error (HTTP status code 400 – Bad Request).

Uncommitted Blobs in the Response

Uncommitted blobs are listed in the response only if the include=uncommittedblobs parameter was specified on the URI. Uncommitted blobs listed in the response do not include any of the following elements:

  • Last-Modified

  • Etag

  • Content-Type

  • Content-Encoding

  • Content-Language

  • Content-MD5

  • Cache-Control

  • Metadata

Returning Result Sets Using a Marker Value

If you specify a value for the maxresults parameter and the number of blobs to return exceeds this value, or exceeds the default value for maxresults, the response body will contain a NextMarker element that indicates the next blob to return on a subsequent request. To return the next set of items, specify the value of NextMarker as the marker parameter on the URI for the subsequent request.

Note that the value of NextMarker should be treated as opaque.

Using a Delimiter to Traverse the Blob Namespace

The delimiter parameter enables the caller to traverse the blob namespace by using a user-configured delimiter. In this way, you can traverse a virtual hierarchy of blobs as though it were a file system. The delimiter may be a single character or a string. When the request includes this parameter, the operation returns a BlobPrefix element. The BlobPrefix element is returned in place of all blobs whose names begin with the same substring up to the appearance of the delimiter character. The value of the BlobPrefix element is substring+delimiter, where substring is the common substring that begins one or more blob names, and delimiter is the value of the delimiter parameter.

You can use the value of BlobPrefix to make a subsequent call to list the blobs that begin with this prefix, by specifying the value of BlobPrefix for the prefix parameter on the request URI.

Note that each BlobPrefix element returned counts toward the maximum result, just as each Blob element does.

Blobs are listed in alphabetical order in the response body.

Cela vous a-t-il été utile ?
(1500 caractères restants)

Ajouts de la communauté

© 2013 Microsoft. Tous droits réservés.
facebook page visit twitter rss feed newsletter