Skip to content
Permalink
Browse files

😍

  • Loading branch information...
RafiZz committed Feb 15, 2019
1 parent c37ec72 commit 3b0188db86d54a8afc3a1896cc9bed13cfea824f
Showing with 10 additions and 6 deletions.
  1. +10 −6 ir_attachment_s3/models/ir_attachment.py
@@ -5,13 +5,14 @@
import hashlib
import logging

from odoo import api, models, _, fields, tools
from odoo import api, models, _, fields, tools, exceptions
from odoo.tools.safe_eval import safe_eval

_logger = logging.getLogger(__name__)

try:
import boto3
import botocore
except:
_logger.debug('boto3 package is required which is not \
found on your installation')
@@ -110,12 +111,15 @@ def _inverse_datas(self):
fname = hashlib.sha1(bin_data).hexdigest()

bucket_name = self._get_s3_settings('s3.bucket', 'S3_BUCKET')
s3.Bucket(bucket_name).put_object(
Key=fname,
Body=bin_data,
ACL='public-read',
ContentType=attach.mimetype,
try:
s3.Bucket(bucket_name).put_object(
Key=fname,
Body=bin_data,
ACL='public-read',
ContentType=attach.mimetype,
)
except botocore.exceptions.ClientError as e:
raise exceptions.UserError(str(e))

vals = {
'file_size': len(bin_data),

0 comments on commit 3b0188d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.