[12.0][IMP] attachment_azure: don't get blob content if we only need its size

This commit is contained in:
Nils Hamerlinck
2021-09-04 20:33:43 +07:00
parent 33d7ed3b91
commit dd245bd7c6
+4 -1
View File
@@ -150,7 +150,10 @@ class IrAttachment(models.Model):
key = fname.replace("azure://", "", 1).lower() key = fname.replace("azure://", "", 1).lower()
try: try:
blob_client = container_client.get_blob_client(key) blob_client = container_client.get_blob_client(key)
read = base64.b64encode(blob_client.download_blob().readall()) if bin_size:
return blob_client.get_blob_properties()['size']
else:
read = base64.b64encode(blob_client.download_blob().readall())
except HttpResponseError: except HttpResponseError:
read = "" read = ""
_logger.info("Attachment '%s' missing on object storage", fname) _logger.info("Attachment '%s' missing on object storage", fname)