How to know the size of an Azure blob object via Python Azure SDK
up vote
0
down vote
favorite
Following the Microsoft Azure documentation for Python developers. The azure.storage.blob.models.Blob
class does have a private method called __sizeof__()
. But it returns a constant value of 16, whether the blob is empty (0 byte) or 1 GB. Is there any method/attribute of a blob object with which I can dynamically check the size of the object?
To be clearer, this is how my source code looks like.
for i in blobService.list_blobs(container_name=container, prefix=path):
if i.name.endswith('.json') and r'CIJSONTM.json/part' in i.name:
#do some stuffs
However, the data pool contains many empty blobs having legitimate names, and before I #do some stuffs
, I want to have an additional check on the size to judge whether I am dealing with an empty blob.
Also, bonus for what exactly does the __sizeof__()
method give, if not the size of the blob object?
python azure azure-storage-blobs sizeof azure-sdk-python
add a comment |
up vote
0
down vote
favorite
Following the Microsoft Azure documentation for Python developers. The azure.storage.blob.models.Blob
class does have a private method called __sizeof__()
. But it returns a constant value of 16, whether the blob is empty (0 byte) or 1 GB. Is there any method/attribute of a blob object with which I can dynamically check the size of the object?
To be clearer, this is how my source code looks like.
for i in blobService.list_blobs(container_name=container, prefix=path):
if i.name.endswith('.json') and r'CIJSONTM.json/part' in i.name:
#do some stuffs
However, the data pool contains many empty blobs having legitimate names, and before I #do some stuffs
, I want to have an additional check on the size to judge whether I am dealing with an empty blob.
Also, bonus for what exactly does the __sizeof__()
method give, if not the size of the blob object?
python azure azure-storage-blobs sizeof azure-sdk-python
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Following the Microsoft Azure documentation for Python developers. The azure.storage.blob.models.Blob
class does have a private method called __sizeof__()
. But it returns a constant value of 16, whether the blob is empty (0 byte) or 1 GB. Is there any method/attribute of a blob object with which I can dynamically check the size of the object?
To be clearer, this is how my source code looks like.
for i in blobService.list_blobs(container_name=container, prefix=path):
if i.name.endswith('.json') and r'CIJSONTM.json/part' in i.name:
#do some stuffs
However, the data pool contains many empty blobs having legitimate names, and before I #do some stuffs
, I want to have an additional check on the size to judge whether I am dealing with an empty blob.
Also, bonus for what exactly does the __sizeof__()
method give, if not the size of the blob object?
python azure azure-storage-blobs sizeof azure-sdk-python
Following the Microsoft Azure documentation for Python developers. The azure.storage.blob.models.Blob
class does have a private method called __sizeof__()
. But it returns a constant value of 16, whether the blob is empty (0 byte) or 1 GB. Is there any method/attribute of a blob object with which I can dynamically check the size of the object?
To be clearer, this is how my source code looks like.
for i in blobService.list_blobs(container_name=container, prefix=path):
if i.name.endswith('.json') and r'CIJSONTM.json/part' in i.name:
#do some stuffs
However, the data pool contains many empty blobs having legitimate names, and before I #do some stuffs
, I want to have an additional check on the size to judge whether I am dealing with an empty blob.
Also, bonus for what exactly does the __sizeof__()
method give, if not the size of the blob object?
python azure azure-storage-blobs sizeof azure-sdk-python
python azure azure-storage-blobs sizeof azure-sdk-python
asked Nov 19 at 7:04
Della
243110
243110
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27
add a comment |
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I want to have an additional check on the size to judge whether I am dealing with an empty blob.
We could use the BlobProperties().content_length to check whether it is a empty blob.
BlockBlobService.get_blob_properties(block_blob_service,container_name,blob_name).properties.content_length
The following is the demo code how to get the blob content_length :
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='accoutName', account_key='accountKey')
container_name ='containerName'
block_blob_service.create_container(container_name)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
length = BlockBlobService.get_blob_properties(block_blob_service,container_name,blob.name).properties.content_length
print("t Blob name: " + blob.name)
print(length)
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about__sizeof__()
? Have you looked into the source code?
– Tom Sun
Nov 20 at 9:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I want to have an additional check on the size to judge whether I am dealing with an empty blob.
We could use the BlobProperties().content_length to check whether it is a empty blob.
BlockBlobService.get_blob_properties(block_blob_service,container_name,blob_name).properties.content_length
The following is the demo code how to get the blob content_length :
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='accoutName', account_key='accountKey')
container_name ='containerName'
block_blob_service.create_container(container_name)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
length = BlockBlobService.get_blob_properties(block_blob_service,container_name,blob.name).properties.content_length
print("t Blob name: " + blob.name)
print(length)
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about__sizeof__()
? Have you looked into the source code?
– Tom Sun
Nov 20 at 9:37
add a comment |
up vote
1
down vote
accepted
I want to have an additional check on the size to judge whether I am dealing with an empty blob.
We could use the BlobProperties().content_length to check whether it is a empty blob.
BlockBlobService.get_blob_properties(block_blob_service,container_name,blob_name).properties.content_length
The following is the demo code how to get the blob content_length :
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='accoutName', account_key='accountKey')
container_name ='containerName'
block_blob_service.create_container(container_name)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
length = BlockBlobService.get_blob_properties(block_blob_service,container_name,blob.name).properties.content_length
print("t Blob name: " + blob.name)
print(length)
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about__sizeof__()
? Have you looked into the source code?
– Tom Sun
Nov 20 at 9:37
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I want to have an additional check on the size to judge whether I am dealing with an empty blob.
We could use the BlobProperties().content_length to check whether it is a empty blob.
BlockBlobService.get_blob_properties(block_blob_service,container_name,blob_name).properties.content_length
The following is the demo code how to get the blob content_length :
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='accoutName', account_key='accountKey')
container_name ='containerName'
block_blob_service.create_container(container_name)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
length = BlockBlobService.get_blob_properties(block_blob_service,container_name,blob.name).properties.content_length
print("t Blob name: " + blob.name)
print(length)
I want to have an additional check on the size to judge whether I am dealing with an empty blob.
We could use the BlobProperties().content_length to check whether it is a empty blob.
BlockBlobService.get_blob_properties(block_blob_service,container_name,blob_name).properties.content_length
The following is the demo code how to get the blob content_length :
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='accoutName', account_key='accountKey')
container_name ='containerName'
block_blob_service.create_container(container_name)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
length = BlockBlobService.get_blob_properties(block_blob_service,container_name,blob.name).properties.content_length
print("t Blob name: " + blob.name)
print(length)
answered Nov 19 at 8:24
Tom Sun
15.9k2921
15.9k2921
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about__sizeof__()
? Have you looked into the source code?
– Tom Sun
Nov 20 at 9:37
add a comment |
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about__sizeof__()
? Have you looked into the source code?
– Tom Sun
Nov 20 at 9:37
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Thanks. Curiously, the method is absent in the documentation it seems. And what does the ' __sizeof__()' method do here?
– Della
Nov 20 at 9:33
Could you please add more information about
__sizeof__()
? Have you looked into the source code?– Tom Sun
Nov 20 at 9:37
Could you please add more information about
__sizeof__()
? Have you looked into the source code?– Tom Sun
Nov 20 at 9:37
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369766%2fhow-to-know-the-size-of-an-azure-blob-object-via-python-azure-sdk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your linked blob class has a metadata property - can you check what's in there? Perhaps, as per your example: i.metadata['size'] or the equivalent python to get a value from a named key value pair?
– user3012708
Nov 19 at 8:27