I am using Azure SDK for .Net (version 9.3.1, Platform .NET-Standard 2.0) for working with Azure Blob storage, and having troubles with referencing block blobs having blank space in the blob name. I have uploaded a block blob JSON Test.json into a private container via Azure Storage Explorer 1.6.1.
Blob properties as per Azure Storage Explorer:
Name: `JSON Test.json`
URI: `https://<myaccountname>/<mycontainername>/JSON%20Test.json`
Now, I am trying to check whether that Blob exists with CloudBlockBlob.ExistsAsync() method passing to GetBlockBlobReference non-encoded filename JSON Test.json
And getting FALSE as result.
Now, I am creating a blob programatically in a different container, passing the same filename non-encoded, using the same GetBlockBlobReference and getting created a blob with encoded filename.
Name: `JSON%20Test.json`
URI: `https://<myaccountname>/<mycontainername2>/JSON%20Test.json`
What I am doing wrong? Why my block blob with blank space in its name created via Azure Storage Explorer is not found while referencing it with non-encoded filename? When creating a block blob programatically a passing non-encoded filename, why the filename gets encoded via the wire?
Please help.
Thanks a lot in advance!
public async Task<bool> CheckExistsAsync(string connectionString, string containerName, string fileName)
{
var blockBlob = GetBlockBlobReference(connectionString, containerName, fileName);
return await blockBlob.ExistsAsync();
}
private static CloudBlockBlob GetBlockBlobReference(string connectionString, string containerName, string fileName)
{
return CloudStorageAccount
.Parse(connectionString)
.CreateCloudBlobClient()
.GetContainerReference(containerName)
.GetBlockBlobReference(fileName);
}
