Merge pull request #328 from vrenaville/fix_read_azure

fix: do not raise error if file is not reachable (for developer mode)
This commit is contained in:
Vincent Renaville
2022-01-24 11:02:26 +01:00
committed by GitHub
co-authored by GitHub
+10
View File
@@ -132,7 +132,14 @@ class IrAttachment(models.Model):
def _get_azure_container(self, container_name=None):
if not container_name:
container_name = self._get_container_name()
try:
blob_service_client = self._get_blob_service_client()
except exceptions.UserError:
_logger.exception(
"error accessing to storage '%s' please check credentials ",
container_name
)
return False
container_client = blob_service_client.get_container_client(container_name)
if not container_client.exists():
try:
@@ -152,6 +159,9 @@ class IrAttachment(models.Model):
else:
container_name = None
container_client = self._get_azure_container(container_name)
# if container cannot be retrived, abort reading from azure storage
if not container_client:
return ''
try:
blob_client = container_client.get_blob_client(key)
read = base64.b64encode(blob_client.download_blob().readall())