Azure / Azure/azure-storage-cpplite

API given error incorrectly even though it could connect and download blob

Open
#67 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
26
Forks
50
PR merge metrics
No merged PRs in 30d

Description

I tried the sample.cpp provided with a little modification for logging and error checking. Please see below code. I gave correct credentials, the container and blob which i am trying to download exist and i could successfully download blob from blob storage.

But, i get error while creating storage_account, blob_client, blob client wrapper though my credentials are correct. I checked 'errno' variable. Please see the code and guide me if i am using it in a wrong way.

```C++
void checkstatus()
{
if(errno == 0)
{
printf("Success\n");
}
else
{
printf("Failure\n");
}
}

int main()
{
std::shared_ptr cred = nullptr;
cred = std::make_shared(account_name, account_key);

printf("\nCreating account : ");
std::shared_ptr account = std::make_shared(account_name, cred, /* use_https */ true);
checkstatus();

if(NULL != account)
{
printf("\nCreating blob client : ");
auto bC = std::make_shared(account, 2);
checkstatus();

std::string containerName = "con1";
std::string blobName = "1.txt";

bool exists = true;
printf("\nCreating blob client wrapper : ");
blob_client_wrapper bc(bC);
checkstatus();

printf("\nGet blob property: ");
bc.get_blob_property(containerName, blobName);
checkstatus();

printf("\nChecking does container exist: ");
exists = bc.container_exists(containerName);
checkstatus();

printf("\nChecking does blob exist: ");
exists = bc.blob_exists(containerName, "1.txt");
checkstatus();
if(!exists)
{
printf("\n Blob name does not exist");
}

time_t last_modified;
printf("\nDownloading file");
bc.download_blob_to_file(containerName, blobName, "./13.txt", last_modified);
std::cout <<"Download Blob done: " << errno << std::endl;
}
else
{
std::cout <<"Download Error: " << errno << std::endl;
}

return 0;

}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.