mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 16:48:36 +00:00
fixup! attachment_s3: Add set ACL function
This commit is contained in:
@@ -16,6 +16,7 @@ _logger = logging.getLogger(__name__)
|
|||||||
try:
|
try:
|
||||||
import boto3
|
import boto3
|
||||||
from botocore.exceptions import ClientError, EndpointConnectionError
|
from botocore.exceptions import ClientError, EndpointConnectionError
|
||||||
|
from botocore.errorfactory import NoSuchKey
|
||||||
except ImportError:
|
except ImportError:
|
||||||
boto3 = None # noqa
|
boto3 = None # noqa
|
||||||
ClientError = None # noqa
|
ClientError = None # noqa
|
||||||
@@ -118,6 +119,7 @@ class IrAttachment(models.Model):
|
|||||||
_logger.exception(
|
_logger.exception(
|
||||||
"error getting bucket from object storage"
|
"error getting bucket from object storage"
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
key = s3uri.item()
|
key = s3uri.item()
|
||||||
try:
|
try:
|
||||||
obj = bucket.Object(key=key)
|
obj = bucket.Object(key=key)
|
||||||
@@ -126,6 +128,10 @@ class IrAttachment(models.Model):
|
|||||||
"ACL %s successfully set on object %s" % (acl, fname)
|
"ACL %s successfully set on object %s" % (acl, fname)
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
except NoSuchKey:
|
||||||
|
_logger.exception(
|
||||||
|
"Object %s does not exists on S3 bucket" % fname
|
||||||
|
)
|
||||||
except ClientError:
|
except ClientError:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
"Cannot set ACL %s on object %s" % (acl, fname)
|
"Cannot set ACL %s on object %s" % (acl, fname)
|
||||||
|
|||||||
Reference in New Issue
Block a user