Question

I have integrated openstack to my .net solution. I am using CloudFilesProvider to create and delete a container. Is there any provision to check for the existence of a container using C#.

I know it is possible to check by getting ObjectStore and find ContainerExists property. But i am not sure how to get this property filled.

Any help will be greatly appreciated.

Was it helpful?

Solution

ObjectStore is an enumeration that defines the possible values returned by calls like IObjectStorageProvider.CreateContainer. For example, you could get an ObjectStore by attempting to create the container you're checking, and the return value would be ContainerExists if the container already exists. Unfortunately you could always end up with ContainerCreated returned by that call, i.e. if you use CreateContainer to check for a container's existence, then even if the container didn't exist before "checking", it would afterwards.

While it's definitely not clean, one option is calling GetContainerMetadata. The call will throw an ItemNotFoundException if the container doesn't exist.

OTHER TIPS

Are you, by chance, using this Container as a CDN?

When deleting a CDN, you must also call the method "DisableCDNOnContainer" against the Container. Also, if you call the method "ListCDNContainers", you must filter out deleted CDN Containers by checking the property "CDNEnabled".

This is because deleted Containers "hang around" until their ttl expires.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top