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.
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.