Skip to content

Commit ca15334

Browse files
committed
[REF] deal with stream on base_attachment_object_storage
1 parent 9e38e3a commit ca15334

File tree

3 files changed

+24
-66
lines changed

3 files changed

+24
-66
lines changed

attachment_s3/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
from . import models

attachment_s3/models/ir_binary.py

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
from . import models
2+
from odoo.http import Stream
3+
4+
5+
old_from_attachment = Stream.from_attachment
6+
7+
8+
@classmethod
9+
def from_attachment(cls, attachment):
10+
if attachment.store_fname and attachment._is_file_from_a_store(attachment.store_fname):
11+
self = cls(
12+
mimetype=attachment.mimetype,
13+
download_name=attachment.name,
14+
conditional=True,
15+
etag=attachment.checksum,
16+
)
17+
self.type = 'data'
18+
self.data = attachment.raw
19+
self.last_modified = attachment['__last_update']
20+
self.size = len(self.data)
21+
return self
22+
return old_from_attachment(attachment)
23+
24+
25+
Stream.from_attachment = from_attachment

0 commit comments

Comments
 (0)