fixup! fixup! attachment_s3: Add set ACL function

This commit is contained in:
Akim Juillerat
2020-01-31 12:42:30 +01:00
parent 6de4ced0f5
commit 4d04588125
+4 -3
View File
@@ -16,7 +16,6 @@ _logger = logging.getLogger(__name__)
try:
import boto3
from botocore.exceptions import ClientError, EndpointConnectionError
from botocore.errorfactory import NoSuchKey
except ImportError:
boto3 = None # noqa
ClientError = None # noqa
@@ -128,11 +127,13 @@ class IrAttachment(models.Model):
"ACL %s successfully set on object %s" % (acl, fname)
)
return True
except NoSuchKey:
except ClientError as e:
error_code = e.response['Error']['Code']
if error_code == "NoSuchKey":
_logger.exception(
"Object %s does not exists on S3 bucket" % fname
)
except ClientError:
else:
_logger.exception(
"Cannot set ACL %s on object %s" % (acl, fname)
)