Skip to content

Commit 52784cf

Browse files
committed
Add handling and logging for blobs that not block type
1 parent ba73744 commit 52784cf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,19 @@ private CloudBlockBlob GetBlockBlobReference(string path)
783783

784784
string blobPath = this.FixPath(path);
785785

786+
var blobReference = this.cloudBlobContainer.GetBlobReferenceFromServer(blobPath);
786787
// Only make the request if there is an actual path. See issue 8.
787788
// https://github.com/JimBobSquarePants/UmbracoFileSystemProviders.Azure/issues/8
788-
return !string.IsNullOrWhiteSpace(path)
789-
? this.cloudBlobContainer.GetBlockBlobReference(blobPath)
790-
: null;
789+
if (blobReference.BlobType == BlobType.BlockBlob && !string.IsNullOrWhiteSpace(path))
790+
{
791+
return blobReference as CloudBlockBlob;
792+
}
793+
else
794+
{
795+
Current.Logger.Error<AzureBlobFileSystem>($"A media item '{path}' was requested but it's blob type was {blobReference.BlobType} when it should be BlockBlob");
796+
return null;
797+
}
798+
791799
}
792800

793801
/// <summary>

0 commit comments

Comments
 (0)