Click or drag to resize
CloudFilesProviderListObjects Method
Lists the objects in a container.

Namespace: net.openstack.Providers.Rackspace
Assembly: openstacknet (in openstacknet.dll) Version: 1.7.7+Branch.master.Sha.25d803f397c8693c2c13777ef6675f796f520f2c
Syntax
public IEnumerable<ContainerObject> ListObjects(
	string container,
	Nullable<int> limit = null,
	string marker = null,
	string markerEnd = null,
	string prefix = null,
	string region = null,
	bool useInternalUrl = false,
	CloudIdentity identity = null
)

Parameters

container
Type: SystemString
The container name.
limit (Optional)
Type: SystemNullableInt32
The maximum number of objects to return. If the value is , a provider-specific default is used.
marker (Optional)
Type: SystemString
When specified, only objects with names greater than marker are returned. If the value is , the list starts at the beginning.
markerEnd (Optional)
Type: SystemString
When specified, only objects with names less than markerEnd are returned. If the value is , the list proceeds to the end, or until the limit is reached.
prefix (Optional)
Type: SystemString
Prefix of object names to include
region (Optional)
Type: SystemString
The region in which to execute this action. If not specified, the user's default region will be used.
useInternalUrl (Optional)
Type: SystemBoolean
to use the endpoint's InternalURL; otherwise to use the endpoint's PublicURL.
identity (Optional)
Type: net.openstack.Core.DomainCloudIdentity
The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.

Return Value

Type: IEnumerableContainerObject
A collection of ContainerObject objects containing the details of the specified objects.

Implements

IObjectStorageProviderListObjects(String, NullableInt32, String, String, String, String, Boolean, CloudIdentity)
Exceptions
ExceptionCondition
ArgumentNullExceptionIf container is .
ArgumentExceptionIf container is empty.
ContainerNameExceptionIf container is not a valid container name.
ArgumentOutOfRangeExceptionIf limit is less than 0.
NotSupportedException If the provider does not support the given identity type.

-or-

The specified region is not supported.

-or-

useInternalUrl is and the provider does not support internal URLs.

InvalidOperationException If identity is and no default identity is available for the provider.

-or-

If region is and no default region is available for the provider.

ResponseExceptionIf the REST API request failed.
Examples

The following example demonstrates the use of this method to output the names of all objects in a container using WriteLine(String, Object). In the example, the pagination details of this method are handled by the helper method ListAllObjects.

public void ListObjects(IObjectStorageProvider provider, string containerName)
{
    Console.WriteLine("Objects in container {0}", containerName);
    foreach (ContainerObject containerObject in ListAllObjects(provider, containerName))
        Console.WriteLine("    {0}", containerObject.Name);
}

private static IEnumerable<ContainerObject> ListAllObjects(
    IObjectStorageProvider provider,
    string containerName,
    int? blockSize = null,
    string prefix = null,
    string region = null,
    bool useInternalUrl = false,
    CloudIdentity identity = null)
{
    if (blockSize <= 0)
        throw new ArgumentOutOfRangeException("blockSize");

    ContainerObject lastContainerObject = null;

    do
    {
        string marker = lastContainerObject != null ? lastContainerObject.Name : null;
        IEnumerable<ContainerObject> containerObjects =
            provider.ListObjects(containerName, blockSize, marker, null, prefix, region, useInternalUrl, identity);
        lastContainerObject = null;
        foreach (ContainerObject containerObject in containerObjects)
        {
            lastContainerObject = containerObject;
            yield return containerObject;
        }
    } while (lastContainerObject != null);
}
Version Information

.NET Framework

Supported in: 4.5

openstack.net

Supported in: 1.6, 1.5, 1.4, 1.3.6
See Also