4
다음 코드는 0의 BLOB 파일 크기 반환푸른 CloubdBlob의 Properties.Length 반환 0
public long GetFileSize(string fileUrl)
{
var blob = GetBlobContainer().GetBlobReference(fileUrl);
return blob == null ? 0 : blob.Properties.Length;
}
를 그가 덩어리를 찾을 수없는 거의있다. 하지만 내가 BLOB를 삭제하면 삭제된다는 것을 알 수 있습니다. 이것은 삭제할 때 작동합니다 :
void DeleteFileFromBlob(string fileUrl, bool deleteSnapshots)
{
var blob = GetBlobContainer().GetBlobReference(fileUrl);
if (deleteSnapshots)
{
var options = new BlobRequestOptions { DeleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots };
blob.DeleteIfExists(options);
}
else blob.DeleteIfExists();
}
기본적으로 위와 동일한 코드이므로 BLOB가 발견됩니다. 나는 모양을 반복하면 내가 저장 바이트 내가 내 스토리지의 총량 계산 때이처럼
내가 올바른 BLOB 파일 크기를 얻을 : 그래서
public long GetStorageUsageByteSize()
{
var blobClient = GetBlobClient();
return (from container in blobClient.ListContainers()
select
(from CloudBlob blob in
container.ListBlobs(new BlobRequestOptions { UseFlatBlobListing = true })
select blob.Properties.Length
).Sum()
).Sum();
}
을, 나는 왜 CloubdBlob을 파악하지 못할 :: Properties.Length는 URL로 GetBlobReference를 사용할 때 0을 반환합니다.
당신이 블롭의 메타 데이터를로드하는 FetchAttributes 방법에 대한 호출을 놓치고있는 것 같습니다
이 지금 버전 2.0.0에서 blob.downloadAttributes()이다 Azure Java SDK : http://javadox.com/com.microsoft.azure/azure-storage/2.0.0/com/microsoft/azure/storage/blob/CloudBlob.html#downloadAttributes –