Azure / azure-storage-cpplite

Lite version of C++ Client Library for Microsoft Azure Storage
MIT License
25 stars 43 forks source link

Function to check validity of client #75

Open ghost opened 4 years ago

ghost commented 4 years ago

Can't find any function to check if a client connection is valid (accessible and sas token valid), until after trying to upload/download something. Ideally I would like to verify my client before operating on it. Something like:

auto cred = std::make_shared<azure::storage_lite::shared_access_signature_credential>(sas_token);
auto account = std::make_shared<azure::storage_lite::storage_account>(ACCOUNT_NAME, cred, USE_HTTPS);
auto client = std::make_shared<azure::storage_lite::blob_client>(account, MAX_CONCURRENCY);
bool valid = client->valid(); // I'm missing something like this

What do you think?

Jinming-Hu commented 4 years ago

@dhollsten I don't think there's is a method that can do what you want and always work. For example, if the sas token only has access to a specific container or blob or blob snapshot, you cannot check validity of the client anyway.

If an API cannot work in all cases, we don't want to provide it.

But there might be some workarounds in some cases. For example, if you know for sure a container exists, and you want to validate the sas token, you can use container_exists.