12345678910111213141516171819 |
- def _file_write(self, value, checksum):
- storage = self._storage()
- if storage[:5] == 's3://':
- access_key_id, secret_key, bucket_name, do_space_url = s3_helper.parse_bucket_url(
- storage)
- s3 = s3_helper.get_resource(
- access_key_id, secret_key, do_space_url)
- s3_bucket = self._connect_to_S3_bucket(s3, bucket_name)
- bin_value = base64.b64decode(value)
- fname = hashlib.sha1(bin_value).hexdigest()
- if encryption_enabled:
- s3.Object(s3_bucket.name, fname).put(Body=bin_value, ServerSideEncryption='AES256')
- else:
- s3.Object(s3_bucket.name, fname).put(Body=bin_value)
- else: # falling back on Odoo's local filestore
- fname = super(S3Attachment, self)._file_write(value, checksum)
- return fname
|