From 9aa54025b04a9b5a4e427139e770c3bd668f5dde Mon Sep 17 00:00:00 2001 From: Nils Hamerlinck Date: Fri, 3 Sep 2021 19:48:14 +0700 Subject: [PATCH] [12.0][IMP] attachment_azure: don't get blob content if we only need its size --- attachment_azure/models/ir_attachment.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/attachment_azure/models/ir_attachment.py b/attachment_azure/models/ir_attachment.py index 23b44cb..227066e 100644 --- a/attachment_azure/models/ir_attachment.py +++ b/attachment_azure/models/ir_attachment.py @@ -150,7 +150,10 @@ class IrAttachment(models.Model): key = fname.replace("azure://", "", 1).lower() try: 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: read = "" _logger.info("Attachment '%s' missing on object storage", fname)