diff --git a/src/corelib/Core/Providers/IObjectStorageProvider.cs b/src/corelib/Core/Providers/IObjectStorageProvider.cs index b5201a913..d8c485665 100644 --- a/src/corelib/Core/Providers/IObjectStorageProvider.cs +++ b/src/corelib/Core/Providers/IObjectStorageProvider.cs @@ -1031,6 +1031,7 @@ public interface IObjectStorageProvider /// When specified, only objects with names greater than are returned. If the value is , the list starts at the beginning. /// When specified, only objects with names less than are returned. If the value is , the list proceeds to the end, or until the is reached. /// Prefix of object names to include + /// A character that define the end of a file name. If the value is '\0', no delimiter are specified. /// The region in which to execute this action. If not specified, the user's default region will be used. /// to use the endpoint's ; otherwise to use the endpoint's . /// The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used. @@ -1062,7 +1063,7 @@ public interface IObjectStorageProvider /// /// /// Show container details and list objects (OpenStack Object Storage API v1 Reference) - IEnumerable ListObjects(string container, int? limit = null, string marker = null, string markerEnd = null, string prefix = null, string region = null, bool useInternalUrl = false, CloudIdentity identity = null); + IEnumerable ListObjects(string container, int? limit = null, string marker = null, string markerEnd = null, string prefix = null, char delimiter = '\0', string region = null, bool useInternalUrl = false, CloudIdentity identity = null); /// /// Creates an object using data from a file. If the destination file already exists, the contents are overwritten. diff --git a/src/corelib/Providers/Rackspace/CloudFilesProvider.cs b/src/corelib/Providers/Rackspace/CloudFilesProvider.cs index cc7b51014..183b5033f 100644 --- a/src/corelib/Providers/Rackspace/CloudFilesProvider.cs +++ b/src/corelib/Providers/Rackspace/CloudFilesProvider.cs @@ -74,7 +74,8 @@ public class CloudFilesProvider : ProviderBase, IObjectS /// implementation. /// public CloudFilesProvider() - : this(null, null, null, null) { } + : this(null, null, null, null) + { } /// /// Initializes a new instance of the class with @@ -83,7 +84,8 @@ public CloudFilesProvider() /// /// The default identity to use for calls that do not explicitly specify an identity. If this value is , no default identity is available so all calls must specify an explicit identity. public CloudFilesProvider(CloudIdentity defaultIdentity) - : this(defaultIdentity, null, null, null) { } + : this(defaultIdentity, null, null, null) + { } /// /// Initializes a new instance of the class with @@ -92,7 +94,8 @@ public CloudFilesProvider(CloudIdentity defaultIdentity) /// /// The implementation of to use for executing REST requests. If this value is , the provider will use a new instance of . public CloudFilesProvider(IRestService restService) - : this(null, null, null, restService) { } + : this(null, null, null, restService) + { } /// /// Initializes a new instance of the class with @@ -101,7 +104,8 @@ public CloudFilesProvider(IRestService restService) /// /// The identity provider to use for authenticating requests to this provider. If this value is , a new instance of is created with no default identity. public CloudFilesProvider(IIdentityProvider identityProvider) - : this(null, null, identityProvider, null) { } + : this(null, null, identityProvider, null) + { } /// /// Initializes a new instance of the class with @@ -111,7 +115,8 @@ public CloudFilesProvider(IIdentityProvider identityProvider) /// The default identity to use for calls that do not explicitly specify an identity. If this value is , no default identity is available so all calls must specify an explicit identity. /// The identity provider to use for authenticating requests to this provider. If this value is , a new instance of is created using as the default identity. public CloudFilesProvider(CloudIdentity defaultIdentity, IIdentityProvider identityProvider) - : this(defaultIdentity, null, identityProvider, null) { } + : this(defaultIdentity, null, identityProvider, null) + { } /// /// Initializes a new instance of the class with @@ -121,7 +126,8 @@ public CloudFilesProvider(CloudIdentity defaultIdentity, IIdentityProvider ident /// The default identity to use for calls that do not explicitly specify an identity. If this value is , no default identity is available so all calls must specify an explicit identity. /// The implementation of to use for executing REST requests. If this value is , the provider will use a new instance of . public CloudFilesProvider(CloudIdentity defaultIdentity, IRestService restService) - : this(defaultIdentity, null, null, restService) { } + : this(defaultIdentity, null, null, restService) + { } /// /// Initializes a new instance of the class with @@ -134,7 +140,8 @@ public CloudFilesProvider(CloudIdentity defaultIdentity, IRestService restServic /// The identity provider to use for authenticating requests to this provider. If this value is , a new instance of is created using as the default identity. /// The implementation of to use for executing REST requests. If this value is , the provider will use a new instance of . public CloudFilesProvider(CloudIdentity defaultIdentity, IIdentityProvider identityProvider, IRestService restService) - : this(defaultIdentity, null, identityProvider, restService) { } + : this(defaultIdentity, null, identityProvider, restService) + { } /// /// Initializes a new instance of the class with @@ -148,7 +155,8 @@ public CloudFilesProvider(CloudIdentity defaultIdentity, IIdentityProvider ident /// The identity provider to use for authenticating requests to this provider. If this value is , a new instance of is created using as the default identity. /// The implementation of to use for executing REST requests. If this value is , the provider will use a new instance of . public CloudFilesProvider(CloudIdentity defaultIdentity, string defaultRegion, IIdentityProvider identityProvider, IRestService restService) - : this(defaultIdentity, defaultRegion, identityProvider, restService, CloudFilesValidator.Default, CloudFilesMetadataProcessor.Default, EncodeDecodeProvider.Default, HttpStatusCodeParser.Default, new BulkDeletionResultMapper(HttpStatusCodeParser.Default)) { } + : this(defaultIdentity, defaultRegion, identityProvider, restService, CloudFilesValidator.Default, CloudFilesMetadataProcessor.Default, EncodeDecodeProvider.Default, HttpStatusCodeParser.Default, new BulkDeletionResultMapper(HttpStatusCodeParser.Default)) + { } /// /// Initializes a new instance of the class with @@ -176,7 +184,8 @@ public CloudFilesProvider(CloudIdentity defaultIdentity, string defaultRegion, I /// If is . /// internal CloudFilesProvider(string defaultRegion, IIdentityProvider identityProvider, IRestService restService, IObjectStorageValidator cloudFilesValidator, IObjectStorageMetadataProcessor cloudFilesMetadataProcessor, IEncodeDecodeProvider encodeDecodeProvider, IStatusParser statusParser, IObjectMapper mapper) - : this(null, defaultRegion, identityProvider, restService, cloudFilesValidator, cloudFilesMetadataProcessor, encodeDecodeProvider, statusParser, mapper) { } + : this(null, defaultRegion, identityProvider, restService, cloudFilesValidator, cloudFilesMetadataProcessor, encodeDecodeProvider, statusParser, mapper) + { } /// /// Initializes a new instance of the class with @@ -274,14 +283,14 @@ public ObjectStore CreateContainer(string container, Dictionary switch (response.StatusCode) { - case HttpStatusCode.Created: - return ObjectStore.ContainerCreated; + case HttpStatusCode.Created: + return ObjectStore.ContainerCreated; - case HttpStatusCode.Accepted: - return ObjectStore.ContainerExists; + case HttpStatusCode.Accepted: + return ObjectStore.ContainerExists; - default: - throw new ResponseException(string.Format("Unexpected status {0} returned by Create Container.", response.StatusCode), response); + default: + throw new ResponseException(string.Format("Unexpected status {0} returned by Create Container.", response.StatusCode), response); } } @@ -310,12 +319,12 @@ public void DeleteContainer(string container, bool deleteObjects = false, string { var objects = ListObjects(container, count, region: region, useInternalUrl: useInternalUrl, identity: identity); - if(objects.Any()) + if (objects.Any()) DeleteObjects(container, objects.Select(o => o.Name), region: region, useInternalUrl: useInternalUrl, identity: identity); } } } - + var urlPath = new Uri(string.Format("{0}/{1}", GetServiceEndpointCloudFiles(identity, region, useInternalUrl), _encodeDecodeProvider.UrlEncode(container))); try @@ -801,7 +810,7 @@ public Dictionary GetObjectMetaData(string container, string obj } /// - public void UpdateObjectHeaders(string container, string objectName, Dictionary headers, string region = null, bool useInternalUrl = false, CloudIdentity identity = null) + public void UpdateObjectHeaders(string container, string objectName, Dictionary headers, string region = null, bool useInternalUrl = false, CloudIdentity identity = null) { if (container == null) throw new ArgumentNullException("container"); @@ -834,7 +843,7 @@ public void UpdateObjectHeaders(string container, string objectName, Dictionary< settings.ContentType = null; ExecuteRESTRequest(identity, urlPath, HttpMethod.POST, headers: hdrs, settings: settings); - + } /// @@ -942,7 +951,7 @@ public void DeleteObjectMetadata(string container, string objectName, string key } /// - public IEnumerable ListObjects(string container, int? limit = null, string marker = null, string markerEnd = null, string prefix = null, string region = null, bool useInternalUrl = false, CloudIdentity identity = null) + public IEnumerable ListObjects(string container, int? limit = null, string marker = null, string markerEnd = null, string prefix = null, char delimiter = '\0', string region = null, bool useInternalUrl = false, CloudIdentity identity = null) { if (container == null) throw new ArgumentNullException("container"); @@ -960,6 +969,9 @@ public IEnumerable ListObjects(string container, int? limit = n if (limit != null) queryStringParameter.Add("limit", limit.ToString()); + if (delimiter != '\0') + queryStringParameter.Add("delimiter", delimiter.ToString()); + if (!string.IsNullOrEmpty(marker)) queryStringParameter.Add("marker", marker); @@ -1258,7 +1270,7 @@ public void DeleteObject(string container, string objectName, Dictionary objectHeader = null; - if(deleteSegments) + if (deleteSegments) objectHeader = GetObjectHeaders(container, objectName, region, useInternalUrl, identity); if (deleteSegments && objectHeader != null && objectHeader.Any(h => h.Key.Equals(ObjectManifest, StringComparison.OrdinalIgnoreCase))) @@ -2592,6 +2604,6 @@ public long LargeFileBatchThreshold public const string ProcessedHeadersHeaderKey = "headers"; #endregion - + } }