From ca3f611cb34ccd5604ec11dcf6b5848c9e198b99 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 27 Apr 2023 08:09:55 +0200 Subject: [PATCH 01/40] [ADD] fs_file: New field to store files --- fs_file/README.rst | 35 ++ fs_file/__init__.py | 0 fs_file/__manifest__.py | 22 + fs_file/fields.py | 260 +++++++++ fs_file/io.py | 134 +++++ fs_file/readme/CONTRIBUTORS.rst | 1 + fs_file/readme/DESCRIPTION.rst | 0 fs_file/readme/USAGE.rst | 100 ++++ fs_file/static/description/icon.png | Bin 0 -> 9455 bytes fs_file/static/description/index.html | 493 ++++++++++++++++++ fs_file/static/src/scss/fsfile_field.scss | 0 .../src/views/fields/fsfile_field.esm.js | 87 ++++ .../static/src/views/fields/fsfile_field.xml | 48 ++ fs_file/tests/__init__.py | 1 + fs_file/tests/models.py | 14 + fs_file/tests/test_fs_file.py | 151 ++++++ 16 files changed, 1346 insertions(+) create mode 100644 fs_file/README.rst create mode 100644 fs_file/__init__.py create mode 100644 fs_file/__manifest__.py create mode 100644 fs_file/fields.py create mode 100644 fs_file/io.py create mode 100644 fs_file/readme/CONTRIBUTORS.rst create mode 100644 fs_file/readme/DESCRIPTION.rst create mode 100644 fs_file/readme/USAGE.rst create mode 100644 fs_file/static/description/icon.png create mode 100644 fs_file/static/description/index.html create mode 100644 fs_file/static/src/scss/fsfile_field.scss create mode 100644 fs_file/static/src/views/fields/fsfile_field.esm.js create mode 100644 fs_file/static/src/views/fields/fsfile_field.xml create mode 100644 fs_file/tests/__init__.py create mode 100644 fs_file/tests/models.py create mode 100644 fs_file/tests/test_fs_file.py diff --git a/fs_file/README.rst b/fs_file/README.rst new file mode 100644 index 0000000000..38929e8775 --- /dev/null +++ b/fs_file/README.rst @@ -0,0 +1,35 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. + + +Automatic changelog generation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`HISTORY.rst` can be auto generated using `towncrier `_. + +Just put towncrier compatible changelog fragments into `readme/newsfragments` +and the changelog file will be automatically generated and updated when a new fragment is added. + +Please refer to `towncrier` documentation to know more. + +NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. +If you need to run it manually, refer to `OCA/maintainer-tools README `_. diff --git a/fs_file/__init__.py b/fs_file/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_file/__manifest__.py b/fs_file/__manifest__.py new file mode 100644 index 0000000000..eb996d1786 --- /dev/null +++ b/fs_file/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Fs File", + "summary": """ + Field to store files into filesystem storages""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/storage", + "depends": ["fs_attachment"], + "data": [], + "demo": [], + "maintainers": ["lmignon"], + "development_status": "Alpha", + "assets": { + "web.assets_backend": [ + "fs_file/static/src/**/*", + ], + }, +} diff --git a/fs_file/fields.py b/fs_file/fields.py new file mode 100644 index 0000000000..29a92f12f3 --- /dev/null +++ b/fs_file/fields.py @@ -0,0 +1,260 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# pylint: disable=method-required-super +import base64 +import itertools +from io import IOBase + +from odoo import fields + +from .io import FSFileBytesIO + + +class FSFile(fields.Binary): + """ + This field is a binary field that stores the file content in an external + filesystem storage referenced by a storage code. + + A major difference with the standard Odoo binary field is that the value + is not encoded in base64 but is a bytes object. + + Moreover, the field is designed to always return an instance of + :class:`FSFileBytesIO` when reading the value. This class is a file-like + object that can be used to read the file content and to get information + about the file (filename, mimetype, url, ...). + + To update the value of the field, the following values are accepted: + + - a bytes object (e.g. ``b"..."``) + - a dict with the following keys: + - ``filename``: the filename of the file + - ``content``: the content of the file encoded in base64 + - a FSFileBytesIO instance + - a file-like object (e.g. an instance of :class:`io.BytesIO`) + + When the value is provided is a bytes object the filename is set to the + name of the field. You can override this behavior by providing specifying + a fs_filename key in the context. For example: + + .. code-block:: python + + record.with_context(fs_filename='my_file.txt').write({ + 'field': b'...', + }) + + The same applies when the value is provided as a file-like object but the + filename is set to the name of the file-like object or not a property of + the file-like object. (e.g. ``io.BytesIO(b'...')``). + + + When the value is converted to the read format, it's always an instance of + dict with the following keys: + + - ``filename``: the filename of the file + - ``mimetype``: the mimetype of the file + - ``size``: the size of the file + - ``url``: the url to access the file + + """ + + type = "fs_file" + + attachment: bool = True + storage_code: str = None + + def __init__(self, storage_code: str = None, **kwargs): + self.storage_code = storage_code + kwargs["attachment"] = True + super().__init__(**kwargs) + + def read(self, records): + domain = [ + ("res_model", "=", records._name), + ("res_field", "=", self.name), + ("res_id", "in", records.ids), + ] + data = { + att.res_id: FSFileBytesIO(attachment=att) + for att in records.env["ir.attachment"].sudo().search(domain) + } + records.env.cache.insert_missing(records, self, map(data.get, records._ids)) + + def create(self, record_values): + if not record_values: + return + env = record_values[0][0].env + with env.norecompute(): + ir_attachment = ( + env["ir.attachment"] + .sudo() + .with_context( + storage_code=self.storage_code, + binary_field_real_user=env.user, + ) + ) + for record, value in record_values: + if value: + cache_value = self.convert_to_cache(value, record) + attachment = ir_attachment.create( + { + "name": cache_value.name, + "raw": cache_value.getvalue(), + "res_model": record._name, + "res_field": self.name, + "res_id": record.id, + "type": "binary", + } + ) + record.env.cache.update( + record, + self, + [FSFileBytesIO(attachment=attachment)], + dirty=False, + ) + + def write(self, records, value): + # the code is copied from the standard Odoo Binary field + # with the following changes: + # - the value is not encoded in base64 and we therefore write on + # ir.attachment.raw instead of ir.attachment.datas + # - we use the storage_code to store the attachment in the right + # filesystem storage + + # discard recomputation of self on records + records.env.remove_to_compute(self, records) + # update the cache, and discard the records that are not modified + cache = records.env.cache + cache_value = self.convert_to_cache(value, records) + records = cache.get_records_different_from(records, self, cache_value) + if not records: + return records + if self.store: + # determine records that are known to be not null + not_null = cache.get_records_different_from(records, self, None) + + cache.update(records, self, itertools.repeat(cache_value)) + + # retrieve the attachments that store the values, and adapt them + if self.store and any(records._ids): + real_records = records.filtered("id") + atts = ( + records.env["ir.attachment"] + .sudo() + .with_context( + storage_code=self.storage_code, + binary_field_real_user=records.env.user, + ) + ) + if not_null: + atts = atts.search( + [ + ("res_model", "=", self.model_name), + ("res_field", "=", self.name), + ("res_id", "in", real_records.ids), + ] + ) + if value: + filename = cache_value.name + content = cache_value.getvalue() + # update the existing attachments + atts.write({"raw": content, "name": filename}) + atts_records = records.browse(atts.mapped("res_id")) + # create the missing attachments + missing = real_records - atts_records + if missing: + create_vals = [] + for record in missing: + create_vals.append( + { + "name": filename, + "res_model": record._name, + "res_field": self.name, + "res_id": record.id, + "type": "binary", + "raw": content, + } + ) + created = atts.create(create_vals) + for att in created: + record = records.browse(att.res_id) + record.env.cache.update( + record, self, [FSFileBytesIO(attachment=att)], dirty=False + ) + else: + atts.unlink() + + return records + + def _get_filename(self, record): + return record.env.context.get("fs_filename", self.name) + + def convert_to_cache(self, value, record, validate=True): + if value is None or value is False: + return None + if isinstance(value, FSFileBytesIO): + return value + if isinstance(value, dict): + return FSFileBytesIO( + name=value["filename"], value=base64.b64decode(value["content"]) + ) + if isinstance(value, IOBase): + name = getattr(value, "name", None) + if name is None: + name = self._get_filename(record) + return FSFileBytesIO(name=name, value=value) + if isinstance(value, bytes): + return FSFileBytesIO( + name=self._get_filename(record), value=base64.b64decode(value) + ) + raise ValueError( + "Invalid value for %s: %r\n" + "Should be base64 encoded bytes or a file-like object" % (self, value) + ) + + def convert_to_write(self, value, record): + return self.convert_to_cache(value, record) + + def __convert_to_column(self, value, record, values=None, validate=True): + if value is None or value is False: + return None + if isinstance(value, IOBase): + if hasattr(value, "getvalue"): + value = value.getvalue() + else: + v = value.read() + value.seek(0) + value = v + return value + if isinstance(value, bytes): + return base64.b64decode(value) + raise ValueError( + "Invalid value for %s: %r\n" + "Should be base64 encoded bytes or a file-like object" % (self, value) + ) + + def __convert_to_record(self, value, record): + if value is None or value is False: + return None + if isinstance(value, IOBase): + return value + if isinstance(value, bytes): + return FSFileBytesIO(value=value) + raise ValueError( + "Invalid value for %s: %r\n" + "Should be base64 encoded bytes or a file-like object" % (self, value) + ) + + def convert_to_read(self, value, record, use_name_get=True): + if value is None or value is False: + return None + if isinstance(value, FSFileBytesIO): + return { + "filename": value.name, + "url": value.internal_url, + "size": value.size, + "mimetype": value.mimetype, + } + raise ValueError( + "Invalid value for %s: %r\n" + "Should be base64 encoded bytes or a file-like object" % (self, value) + ) diff --git a/fs_file/io.py b/fs_file/io.py new file mode 100644 index 0000000000..c5b2e873bf --- /dev/null +++ b/fs_file/io.py @@ -0,0 +1,134 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# pylint: disable=method-required-super +import io +import os.path + +from odoo.addons.fs_attachment.models.ir_attachment import IrAttachment + + +class FSFileBytesIO: + def __init__( + self, + attachment: IrAttachment = None, + name: str = None, + value: bytes | io.IOBase = None, + ) -> None: + """ + This class holds the information related to FSFile field. It can be + used to assign a value to a FSFile field. In such a case, you can pass + the name and the file content as parameters. + + When + + :param attachment: the attachment to use to store the file. + :param name: the name of the file. If not provided, the name will be + taken from the attachment or the io.IOBase. + :param value: the content of the file. It can be bytes or an io.IOBase. + """ + self._is_new: bool = attachment is None + self._buffer: io.IOBase = None + self._attachment: IrAttachment = attachment + if name and attachment: + raise ValueError("Cannot set name and attachment at the same time") + if value: + if isinstance(value, io.IOBase): + self._buffer = value + if not hasattr(value, "name") and name: + self._buffer.name = name + elif not name: + raise ValueError( + "name must be set when value is an io.IOBase " + "and is not provided by the io.IOBase" + ) + elif isinstance(value, bytes): + self._buffer = io.BytesIO(value) + if not name: + raise ValueError("name must be set when value is bytes") + self._buffer.name = name + else: + raise ValueError("value must be bytes or io.BytesIO") + + @property + def write_buffer(self) -> io.BytesIO: + if self._buffer is None: + name = self._attachment.name if self._attachment else None + self._buffer = io.BytesIO() + self._buffer.name = name + return self._buffer + + @property + def name(self) -> str | None: + name = ( + self._attachment.name + if self._attachment + else self._buffer.name + if self._buffer + else None + ) + if name: + return os.path.basename(name) + return None + + @name.setter + def name(self, value: str) -> None: + # the name should only be updatable while the file is not yet stored + # TODO, we could also allow to update the name of the file and rename + # the file in the external file system + if self._is_new: + self.write_buffer.name = value + else: + raise ValueError( + "The name of the file can only be updated while the file is not " + "yet stored" + ) + + @property + def mimetype(self) -> str | None: + return self._attachment.mimetype if self._attachment else None + + @property + def size(self) -> int: + return self._attachment.file_size if self._attachment else len(self._buffer) + + @property + def url(self) -> str | None: + return self._attachment.url if self._attachment else None + + @property + def internal_url(self) -> str | None: + return self._attachment.internal_url if self._attachment else None + + @property + def attachment(self) -> IrAttachment | None: + return self._attachment + + @attachment.setter + def attachment(self, value: IrAttachment) -> None: + self._attachment = value + self._buffer = None + + def open( + self, + mode="rb", + block_size=None, + cache_options=None, + compression=None, + new_version=True, + **kwargs + ) -> io.IOBase: + """ + Return a file-like object that can be used to read and write the file content. + See the documentation of open() into the ir.attachment model from the + fs_attachment module for more information. + """ + if not self._attachment: + raise ValueError("Cannot open a file that is not stored") + return self._attachment.open( + mode=mode, + block_size=block_size, + cache_options=cache_options, + compression=compression, + new_version=new_version, + **kwargs, + ) diff --git a/fs_file/readme/CONTRIBUTORS.rst b/fs_file/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..7106cfd089 --- /dev/null +++ b/fs_file/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +Laurent Mignon diff --git a/fs_file/readme/DESCRIPTION.rst b/fs_file/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_file/readme/USAGE.rst b/fs_file/readme/USAGE.rst new file mode 100644 index 0000000000..5c387cd131 --- /dev/null +++ b/fs_file/readme/USAGE.rst @@ -0,0 +1,100 @@ +The new field **FSFile** has been developed to allows you to store files +in an external filesystem storage. Its design is based on the following +principles: + +* The content of the file must be read from the filesystem only when + needed. +* It must be possible to manipulate the file content as a stream by default. +* Unlike Odoo's Binary field, the content is the raw file content by default + (no base64 encoding). +* To allows to exchange the file content with other systems, writing the + content as base64 is possible. The read operation will return a json + structure with the filename, the mimetype, the size and a url to download the file. + +This design allows to minimize the memory consumption of the server when +manipulating large files and exchanging them with other systems through +the default jsonrpc interface. + +Concretely, this design allows you to write code like this: + +.. code-block:: python + + from IO import BytesIO + from odoo import models, fields + from odoo.addons.fs_file.fields import FSFile + + class MyModel(models.Model): + _name = 'my.model' + + name = fields.Char() + file = FSFile(field_name='filename', storage_code="my_storage") + + # Create a new record with a raw content + my_model = MyModel.create({ + 'name': 'My File', + 'file': BytesIO(b"content"), + }) + + assert(my_model.file.read() == b"content") + + # Create a new record with a base64 encoded content + my_model = MyModel.create({ + 'name': 'My File', + 'file': b"content".encode('base64'), + }) + assert(my_model.file.read() == b"content") + + # Create a new record with a file content + my_model = MyModel.create({ + 'name': 'My File', + 'file': open('my_file.txt', 'rb'), + }) + assert(my_model.file.read() == b"content") + assert(my_model.file.name == "my_file.txt") + + # create a record with a file content as base64 encoded and a filename + # This method is useful to create a record from a file uploaded + # through the web interface. + my_model = MyModel.create({ + 'name': 'My File', + 'file': { + 'filename': 'my_file.txt', + 'content': base64.b64encode(b"content"), + }, + }) + assert(my_model.file.read() == b"content") + assert(my_model.file.name == "my_file.txt") + + # write the content of the file as base64 encoded and a filename + # This method is useful to update a record from a file uploaded + # through the web interface. + my_model.write({ + 'file': { + 'name': 'my_file.txt', + 'file': base64.b64encode(b"content"), + }, + }) + + # the call to read() will return a json structure with the filename, + # the mimetype, the size and a url to download the file. + info = my_model.file.read() + assert(info["file"] == { + "filename": "my_file.txt", + "mimetype": "text/plain", + "size": 7, + "url": "/web/content/1234/my_file.txt", + }) + + # use the field as a file stream + # In such a case, the content is read from the filesystem without being + # stored in memory. + with my_model.file.open("rb) as f: + assert(f.read() == b"content") + + # use the field as a file stream to write the content + # In such a case, the content is written to the filesystem without being + # stored in memory. This kind of approach is useful to manipulate large + # files and to avoid to use too much memory. + # Transactional behaviour is ensured by the implementation! + with my_model.file.open("wb") as f: + f.write(b"content") diff --git a/fs_file/static/description/icon.png b/fs_file/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5Xw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eA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/fs_file/static/description/index.html b/fs_file/static/description/index.html new file mode 100644 index 0000000000..166f0ed9dd --- /dev/null +++ b/fs_file/static/description/index.html @@ -0,0 +1,493 @@ + + + + + + +Fs File + + + +
+

Fs File

+ + +

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runbot

+

Table of contents

+ +
+

Usage

+

The new field FSFile has been developed to allows you to store files +in an external filesystem storage. Its design is based on the following +principles:

+
    +
  • The content of the file must be read from the filesystem only when +needed.
  • +
  • It must be possible to manipulate the file content as a stream by default.
  • +
  • Unlike Odoo’s Binary field, the content is the raw file content by default +(no base64 encoding).
  • +
  • To allows to exchange the file content with other systems, writing the +content as base64 is possible. The read operation will return a json +structure with the filename, the mimetype and a url to download the file.
  • +
+

This design allows to minimize the memory consumption of the server when +manipulating large files and exchanging them with other systems through +the default jsonrpc interface.

+

Concretely, this design allows you to write code like this:

+
+from IO import BytesIO
+from odoo import models, fields
+from odoo.addons.fs_file.fields import FSFile
+
+class MyModel(models.Model):
+    _name = 'my.model'
+
+    name = fields.Char()
+    filename = fields.Char()
+    file = FSFile(field_name='filename', storage_code="my_storage")
+
+# Create a new record with a raw content
+my_model = MyModel.create({
+    'name': 'My File',
+    'filename': 'my_file.txt',
+    'file': BytesIO(b"content"),
+})
+
+assert(my_model.file.read() == b"content")
+assert(my_model.file.name == "my_file.txt")
+
+# Create a new record with a base64 encoded content
+my_model = MyModel.create({
+    'name': 'My File',
+    'filename': 'my_file.txt',
+    'file': b"content".encode('base64'),
+})
+assert(my_model.file.read() == b"content")
+assert(my_model.file.name == "my_file.txt")
+
+# Create a new record with a file content
+with open('my_file.txt', 'rb') as f:
+    f.write(b"content")
+
+my_model = MyModel.create({
+    'name': 'My File',
+    'file': open('my_file.txt', 'rb'),
+})
+assert(my_model.file.read() == b"content")
+assert(my_model.file.name == "my_file.txt")
+
+with open(my_model.file, 'wb') as f:
+    f.write(b"new content")
+
+# the call to read() will return a json structure with the filename,
+# the mimetype and a url to download the file.
+info = my_model.file.read()
+assert(info["file"] == {
+    "filename": "my_file.txt",
+    "mimetype": "text/plain",
+    "url": "/web/content/1234/my_file.txt",
+})
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

lmignon

+

This module is part of the OCA/storage project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/fs_file/static/src/scss/fsfile_field.scss b/fs_file/static/src/scss/fsfile_field.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_file/static/src/views/fields/fsfile_field.esm.js b/fs_file/static/src/views/fields/fsfile_field.esm.js new file mode 100644 index 0000000000..30149cf4c6 --- /dev/null +++ b/fs_file/static/src/views/fields/fsfile_field.esm.js @@ -0,0 +1,87 @@ +/** @odoo-module */ + +/** + * Copyright 2023 ACSONE SA/NV + */ + +import {registry} from "@web/core/registry"; +import {session} from "@web/session"; +import {formatFloat} from "@web/views/fields/formatters"; +import {useService} from "@web/core/utils/hooks"; +import {sprintf} from "@web/core/utils/strings"; +import {getDataURLFromFile} from "@web/core/utils/urls"; +import {standardFieldProps} from "@web/views/fields/standard_field_props"; +import {Component, onWillUpdateProps, useState} from "@odoo/owl"; + +const DEFAULT_MAX_FILE_SIZE = 128 * 1024 * 1024; // 128MB + +export class FSFileField extends Component { + setup() { + this.notification = useService("notification"); + this.state = useState({ + ...this.props.value, + isUploading: false, + }); + onWillUpdateProps((nextProps) => { + this.state.isUploading = false; + const {filename, mimetype, url} = nextProps.value || {}; + this.state.filename = filename; + this.state.mimetype = mimetype; + this.state.url = url; + }); + } + get maxUploadSize() { + return session.max_file_upload_size || DEFAULT_MAX_FILE_SIZE; + } + + edit() { + var input = document.createElement("input"); + input.type = "file"; + input.accept = this.props.acceptedFileExtensions; + input.onchange = (e) => { + const file = e.target.files[0]; + if (file) { + if (file.size > this.maxUploadSize) { + this.notification.add( + sprintf( + this.env._t( + "The file size exceeds the maximum allowed size of %s MB." + ), + formatFloat(this.maxUploadSize / 1024 / 1024) + ), + {type: "danger"} + ); + return; + } + this.uploadFile(file); + } + }; + input.click(); + } + + async uploadFile(file) { + this.state.isUploading = true; + const data = await getDataURLFromFile(file); + this.props.record.update({ + [this.props.name]: { + filename: file.name, + content: data.split(",")[1], + }, + }); + this.state.isUploading = false; + } + + clear() { + this.props.record.update({[this.props.name]: false}); + } +} + +FSFileField.template = "fs_file.FSFileField"; +FSFileField.props = { + ...standardFieldProps, + acceptedFileExtensions: {type: String, optional: true}, +}; +FSFileField.defaultProps = { + acceptedFileExtensions: "*", +}; +registry.category("fields").add("fs_file", FSFileField); diff --git a/fs_file/static/src/views/fields/fsfile_field.xml b/fs_file/static/src/views/fields/fsfile_field.xml new file mode 100644 index 0000000000..34840a5e5e --- /dev/null +++ b/fs_file/static/src/views/fields/fsfile_field.xml @@ -0,0 +1,48 @@ + + + + + Uploading... + +
+ + + + + + + + +
+
+ + + + + + +
+ +
diff --git a/fs_file/tests/__init__.py b/fs_file/tests/__init__.py new file mode 100644 index 0000000000..9c12d36073 --- /dev/null +++ b/fs_file/tests/__init__.py @@ -0,0 +1 @@ +from . import test_fs_file diff --git a/fs_file/tests/models.py b/fs_file/tests/models.py new file mode 100644 index 0000000000..ce035df6a2 --- /dev/null +++ b/fs_file/tests/models.py @@ -0,0 +1,14 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + +from ..fields import FSFile + + +class TestModel(models.Model): + + _name = "test.model" + _log_access = False + + fs_file = FSFile(storage_code="mem_dir") diff --git a/fs_file/tests/test_fs_file.py b/fs_file/tests/test_fs_file.py new file mode 100644 index 0000000000..b57ce2fc9d --- /dev/null +++ b/fs_file/tests/test_fs_file.py @@ -0,0 +1,151 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 +import io +import os +import tempfile + +from odoo_test_helper import FakeModelLoader + +from odoo.tests.common import TransactionCase + +from odoo.addons.fs_storage.models.fs_storage import FSStorage + +from ..io import FSFileBytesIO + + +class TestFsFile(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.loader = FakeModelLoader(cls.env, cls.__module__) + cls.loader.backup_registry() + from .models import TestModel + + cls.loader.update_registry((TestModel,)) + + cls.create_content = b"content" + cls.write_content = b"new content" + cls.tmpfile_path = tempfile.mkstemp(suffix=".txt")[1] + with open(cls.tmpfile_path, "wb") as f: + f.write(cls.create_content) + cls.filename = os.path.basename(cls.tmpfile_path) + + def setUp(self): + super().setUp() + self.temp_dir: FSStorage = self.env["fs.storage"].create( + { + "name": "Temp FS Storage", + "protocol": "memory", + "code": "mem_dir", + "directory_path": "/tmp/", + "model_xmlids": "fs_file.model_test_model", + } + ) + + @classmethod + def tearDownClass(cls): + if os.path.exists(cls.tmpfile_path): + os.remove(cls.tmpfile_path) + cls.loader.restore_registry() + return super().tearDownClass() + + def _test_create(self, fs_file_value): + model = self.env["test.model"] + instance = model.create({"fs_file": fs_file_value}) + self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertEqual(instance.fs_file.getvalue(), self.create_content) + self.assertEqual(instance.fs_file.name, self.filename) + + def _test_write(self, fs_file_value): + instance = self.env["test.model"].create({"fs_file": fs_file_value}) + instance.fs_file = fs_file_value + self.assertEqual(instance.fs_file.getvalue(), self.write_content) + self.assertEqual(instance.fs_file.name, self.filename) + + def test_read(self): + instance = self.env["test.model"].create( + {"fs_file": FSFileBytesIO(name=self.filename, value=self.create_content)} + ) + info = instance.read(["fs_file"])[0] + self.assertDictEqual( + info["fs_file"], + { + "filename": self.filename, + "mimetype": "text/plain", + "size": 7, + "url": instance.fs_file.internal_url, + }, + ) + + def test_create_with_fsfilebytesio(self): + self._test_create(FSFileBytesIO(name=self.filename, value=self.create_content)) + + def test_create_with_dict(self): + self._test_create( + { + "filename": self.filename, + "content": base64.b64encode(self.create_content), + } + ) + + def test_write_with_dict(self): + self._test_write( + { + "filename": self.filename, + "content": base64.b64encode(self.write_content), + } + ) + + def test_create_with_file_like(self): + with open(self.tmpfile_path, "rb") as f: + self._test_create(f) + + def test_create_in_b64(self): + instance = self.env["test.model"].create( + {"fs_file": base64.b64encode(self.create_content)} + ) + self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertEqual(instance.fs_file.getvalue(), self.create_content) + + def test_write_in_b64(self): + instance = self.env["test.model"].create({"fs_file": b"test"}) + instance.write({"fs_file": base64.b64encode(self.create_content)}) + self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertEqual(instance.fs_file.getvalue(), self.create_content) + + def test_write_in_b64_with_specified_filename(self): + self._test_write( + base64.b64encode(self.write_content), {"fs_filename": self.filename} + ) + + def test_create_with_io(self): + instance = self.env["test.model"].create( + {"fs_file": io.BytesIO(self.create_content)} + ) + self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertEqual(instance.fs_file.getvalue(), self.create_content) + + def test_write_with_io(self): + instance = self.env["test.model"].create( + {"fs_file": io.BytesIO(self.create_content)} + ) + instance.write({"fs_file": io.BytesIO(b"test3")}) + self.assertTrue(isinstance(instance.fs_file, io.IOBase)) + self.assertEqual(instance.fs_file.getvalue(), b"test3") + + def test_modify_fsfilebytesio(self): + """If you modify the content of the FSFileBytesIO using the write + method on the FSFileBytesIO object, the changes will be directly applied + and a new file in the storage must be created for the new content. + """ + instance = self.env["test.model"].create( + {"fs_file": FSFileBytesIO(name=self.filename, value=self.create_content)} + ) + initial_store_fname = instance.fs_file.attachment.store_fname + instance.fs_file.write(b"new_content") + self.assertNotEqual( + instance.fs_file.attachment.store_fname, initial_store_fname + ) + self.assertEqual(instance.fs_file.getvalue(), b"new_content") From c49fd3b5d4a7d51a8cd39997883fef3fb6ac647f Mon Sep 17 00:00:00 2001 From: mle Date: Thu, 3 Aug 2023 10:09:56 +0200 Subject: [PATCH 02/40] [IMP] fs_file: Remove storage code; rename FSFileBytesIO -> FSFileValue --- fs_file/fields.py | 182 ++++++++++++++++++++++++++++---- fs_file/io.py | 134 ----------------------- fs_file/readme/CONTRIBUTORS.rst | 1 + fs_file/readme/USAGE.rst | 2 +- fs_file/tests/models.py | 3 +- fs_file/tests/test_fs_file.py | 35 +++--- 6 files changed, 185 insertions(+), 172 deletions(-) delete mode 100644 fs_file/io.py diff --git a/fs_file/fields.py b/fs_file/fields.py index 29a92f12f3..7ec3cff2fa 100644 --- a/fs_file/fields.py +++ b/fs_file/fields.py @@ -3,11 +3,159 @@ # pylint: disable=method-required-super import base64 import itertools -from io import IOBase +import os.path +from io import BytesIO, IOBase from odoo import fields -from .io import FSFileBytesIO +from odoo.addons.fs_attachment.models.ir_attachment import IrAttachment + + +class FSFileValue: + def __init__( + self, + attachment: IrAttachment = None, + name: str = None, + value: bytes | IOBase = None, + ) -> None: + """ + This class holds the information related to FSFile field. It can be + used to assign a value to a FSFile field. In such a case, you can pass + the name and the file content as parameters. + + When + + :param attachment: the attachment to use to store the file. + :param name: the name of the file. If not provided, the name will be + taken from the attachment or the io.IOBase. + :param value: the content of the file. It can be bytes or an io.IOBase. + """ + self._is_new: bool = attachment is None + self._buffer: IOBase = None + self._attachment: IrAttachment = attachment + if name and attachment: + raise ValueError("Cannot set name and attachment at the same time") + if value: + if isinstance(value, IOBase): + self._buffer = value + if not hasattr(value, "name") and name: + self._buffer.name = name + elif not name: + raise ValueError( + "name must be set when value is an io.IOBase " + "and is not provided by the io.IOBase" + ) + elif isinstance(value, bytes): + self._buffer = BytesIO(value) + if not name: + raise ValueError("name must be set when value is bytes") + self._buffer.name = name + else: + raise ValueError("value must be bytes or io.BytesIO") + + @property + def write_buffer(self) -> BytesIO: + if self._buffer is None: + name = self._attachment.name if self._attachment else None + self._buffer = BytesIO() + self._buffer.name = name + return self._buffer + + @property + def name(self) -> str | None: + name = ( + self._attachment.name + if self._attachment + else self._buffer.name + if self._buffer + else None + ) + if name: + return os.path.basename(name) + return None + + @name.setter + def name(self, value: str) -> None: + # the name should only be updatable while the file is not yet stored + # TODO, we could also allow to update the name of the file and rename + # the file in the external file system + if self._is_new: + self.write_buffer.name = value + else: + raise ValueError( + "The name of the file can only be updated while the file is not " + "yet stored" + ) + + @property + def mimetype(self) -> str | None: + return self._attachment.mimetype if self._attachment else None + + @property + def size(self) -> int: + return self._attachment.file_size if self._attachment else len(self._buffer) + + @property + def url(self) -> str | None: + return self._attachment.url if self._attachment else None + + @property + def internal_url(self) -> str | None: + return self._attachment.internal_url if self._attachment else None + + @property + def attachment(self) -> IrAttachment | None: + return self._attachment + + @attachment.setter + def attachment(self, value: IrAttachment) -> None: + self._attachment = value + self._buffer = None + + @property + def read_buffer(self) -> BytesIO: + if self._buffer is None: + content = b"" + name = None + if self._attachment: + content = self._attachment.raw + name = self._attachment.name + self._buffer = BytesIO(content) + self._buffer.name = name + return self._buffer + + def getvalue(self) -> bytes: + buffer = self.read_buffer + current_pos = buffer.tell() + buffer.seek(0) + value = buffer.read() + buffer.seek(current_pos) + return value + + def open( + self, + mode="rb", + block_size=None, + cache_options=None, + compression=None, + new_version=True, + **kwargs + ) -> IOBase: + """ + Return a file-like object that can be used to read and write the file content. + See the documentation of open() into the ir.attachment model from the + fs_attachment module for more information. + """ + if not self._attachment: + raise ValueError("Cannot open a file that is not stored") + return self._attachment.open( + mode=mode, + block_size=block_size, + cache_options=cache_options, + compression=compression, + new_version=new_version, + **kwargs, + ) class FSFile(fields.Binary): @@ -19,7 +167,7 @@ class FSFile(fields.Binary): is not encoded in base64 but is a bytes object. Moreover, the field is designed to always return an instance of - :class:`FSFileBytesIO` when reading the value. This class is a file-like + :class:`FSFileValue` when reading the value. This class is a file-like object that can be used to read the file content and to get information about the file (filename, mimetype, url, ...). @@ -29,7 +177,7 @@ class FSFile(fields.Binary): - a dict with the following keys: - ``filename``: the filename of the file - ``content``: the content of the file encoded in base64 - - a FSFileBytesIO instance + - a FSFileValue instance - a file-like object (e.g. an instance of :class:`io.BytesIO`) When the value is provided is a bytes object the filename is set to the @@ -60,10 +208,8 @@ class FSFile(fields.Binary): type = "fs_file" attachment: bool = True - storage_code: str = None - def __init__(self, storage_code: str = None, **kwargs): - self.storage_code = storage_code + def __init__(self, **kwargs): kwargs["attachment"] = True super().__init__(**kwargs) @@ -74,7 +220,7 @@ def read(self, records): ("res_id", "in", records.ids), ] data = { - att.res_id: FSFileBytesIO(attachment=att) + att.res_id: FSFileValue(attachment=att) for att in records.env["ir.attachment"].sudo().search(domain) } records.env.cache.insert_missing(records, self, map(data.get, records._ids)) @@ -88,7 +234,6 @@ def create(self, record_values): env["ir.attachment"] .sudo() .with_context( - storage_code=self.storage_code, binary_field_real_user=env.user, ) ) @@ -108,7 +253,7 @@ def create(self, record_values): record.env.cache.update( record, self, - [FSFileBytesIO(attachment=attachment)], + [FSFileValue(attachment=attachment)], dirty=False, ) @@ -117,8 +262,6 @@ def write(self, records, value): # with the following changes: # - the value is not encoded in base64 and we therefore write on # ir.attachment.raw instead of ir.attachment.datas - # - we use the storage_code to store the attachment in the right - # filesystem storage # discard recomputation of self on records records.env.remove_to_compute(self, records) @@ -141,7 +284,6 @@ def write(self, records, value): records.env["ir.attachment"] .sudo() .with_context( - storage_code=self.storage_code, binary_field_real_user=records.env.user, ) ) @@ -178,7 +320,7 @@ def write(self, records, value): for att in created: record = records.browse(att.res_id) record.env.cache.update( - record, self, [FSFileBytesIO(attachment=att)], dirty=False + record, self, [FSFileValue(attachment=att)], dirty=False ) else: atts.unlink() @@ -191,19 +333,19 @@ def _get_filename(self, record): def convert_to_cache(self, value, record, validate=True): if value is None or value is False: return None - if isinstance(value, FSFileBytesIO): + if isinstance(value, FSFileValue): return value if isinstance(value, dict): - return FSFileBytesIO( + return FSFileValue( name=value["filename"], value=base64.b64decode(value["content"]) ) if isinstance(value, IOBase): name = getattr(value, "name", None) if name is None: name = self._get_filename(record) - return FSFileBytesIO(name=name, value=value) + return FSFileValue(name=name, value=value) if isinstance(value, bytes): - return FSFileBytesIO( + return FSFileValue( name=self._get_filename(record), value=base64.b64decode(value) ) raise ValueError( @@ -238,7 +380,7 @@ def __convert_to_record(self, value, record): if isinstance(value, IOBase): return value if isinstance(value, bytes): - return FSFileBytesIO(value=value) + return FSFileValue(value=value) raise ValueError( "Invalid value for %s: %r\n" "Should be base64 encoded bytes or a file-like object" % (self, value) @@ -247,7 +389,7 @@ def __convert_to_record(self, value, record): def convert_to_read(self, value, record, use_name_get=True): if value is None or value is False: return None - if isinstance(value, FSFileBytesIO): + if isinstance(value, FSFileValue): return { "filename": value.name, "url": value.internal_url, diff --git a/fs_file/io.py b/fs_file/io.py deleted file mode 100644 index c5b2e873bf..0000000000 --- a/fs_file/io.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright 2023 ACSONE SA/NV -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -# pylint: disable=method-required-super -import io -import os.path - -from odoo.addons.fs_attachment.models.ir_attachment import IrAttachment - - -class FSFileBytesIO: - def __init__( - self, - attachment: IrAttachment = None, - name: str = None, - value: bytes | io.IOBase = None, - ) -> None: - """ - This class holds the information related to FSFile field. It can be - used to assign a value to a FSFile field. In such a case, you can pass - the name and the file content as parameters. - - When - - :param attachment: the attachment to use to store the file. - :param name: the name of the file. If not provided, the name will be - taken from the attachment or the io.IOBase. - :param value: the content of the file. It can be bytes or an io.IOBase. - """ - self._is_new: bool = attachment is None - self._buffer: io.IOBase = None - self._attachment: IrAttachment = attachment - if name and attachment: - raise ValueError("Cannot set name and attachment at the same time") - if value: - if isinstance(value, io.IOBase): - self._buffer = value - if not hasattr(value, "name") and name: - self._buffer.name = name - elif not name: - raise ValueError( - "name must be set when value is an io.IOBase " - "and is not provided by the io.IOBase" - ) - elif isinstance(value, bytes): - self._buffer = io.BytesIO(value) - if not name: - raise ValueError("name must be set when value is bytes") - self._buffer.name = name - else: - raise ValueError("value must be bytes or io.BytesIO") - - @property - def write_buffer(self) -> io.BytesIO: - if self._buffer is None: - name = self._attachment.name if self._attachment else None - self._buffer = io.BytesIO() - self._buffer.name = name - return self._buffer - - @property - def name(self) -> str | None: - name = ( - self._attachment.name - if self._attachment - else self._buffer.name - if self._buffer - else None - ) - if name: - return os.path.basename(name) - return None - - @name.setter - def name(self, value: str) -> None: - # the name should only be updatable while the file is not yet stored - # TODO, we could also allow to update the name of the file and rename - # the file in the external file system - if self._is_new: - self.write_buffer.name = value - else: - raise ValueError( - "The name of the file can only be updated while the file is not " - "yet stored" - ) - - @property - def mimetype(self) -> str | None: - return self._attachment.mimetype if self._attachment else None - - @property - def size(self) -> int: - return self._attachment.file_size if self._attachment else len(self._buffer) - - @property - def url(self) -> str | None: - return self._attachment.url if self._attachment else None - - @property - def internal_url(self) -> str | None: - return self._attachment.internal_url if self._attachment else None - - @property - def attachment(self) -> IrAttachment | None: - return self._attachment - - @attachment.setter - def attachment(self, value: IrAttachment) -> None: - self._attachment = value - self._buffer = None - - def open( - self, - mode="rb", - block_size=None, - cache_options=None, - compression=None, - new_version=True, - **kwargs - ) -> io.IOBase: - """ - Return a file-like object that can be used to read and write the file content. - See the documentation of open() into the ir.attachment model from the - fs_attachment module for more information. - """ - if not self._attachment: - raise ValueError("Cannot open a file that is not stored") - return self._attachment.open( - mode=mode, - block_size=block_size, - cache_options=cache_options, - compression=compression, - new_version=new_version, - **kwargs, - ) diff --git a/fs_file/readme/CONTRIBUTORS.rst b/fs_file/readme/CONTRIBUTORS.rst index 7106cfd089..ce84680771 100644 --- a/fs_file/readme/CONTRIBUTORS.rst +++ b/fs_file/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ Laurent Mignon +Marie Lejeune diff --git a/fs_file/readme/USAGE.rst b/fs_file/readme/USAGE.rst index 5c387cd131..affe202714 100644 --- a/fs_file/readme/USAGE.rst +++ b/fs_file/readme/USAGE.rst @@ -27,7 +27,7 @@ Concretely, this design allows you to write code like this: _name = 'my.model' name = fields.Char() - file = FSFile(field_name='filename', storage_code="my_storage") + file = FSFile() # Create a new record with a raw content my_model = MyModel.create({ diff --git a/fs_file/tests/models.py b/fs_file/tests/models.py index ce035df6a2..145c85c343 100644 --- a/fs_file/tests/models.py +++ b/fs_file/tests/models.py @@ -9,6 +9,7 @@ class TestModel(models.Model): _name = "test.model" + _description = "Test Model" _log_access = False - fs_file = FSFile(storage_code="mem_dir") + fs_file = FSFile() diff --git a/fs_file/tests/test_fs_file.py b/fs_file/tests/test_fs_file.py index b57ce2fc9d..193e31375d 100644 --- a/fs_file/tests/test_fs_file.py +++ b/fs_file/tests/test_fs_file.py @@ -11,7 +11,7 @@ from odoo.addons.fs_storage.models.fs_storage import FSStorage -from ..io import FSFileBytesIO +from ..fields import FSFileValue class TestFsFile(TransactionCase): @@ -54,19 +54,21 @@ def tearDownClass(cls): def _test_create(self, fs_file_value): model = self.env["test.model"] instance = model.create({"fs_file": fs_file_value}) - self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertTrue(isinstance(instance.fs_file, FSFileValue)) self.assertEqual(instance.fs_file.getvalue(), self.create_content) self.assertEqual(instance.fs_file.name, self.filename) - def _test_write(self, fs_file_value): - instance = self.env["test.model"].create({"fs_file": fs_file_value}) + def _test_write(self, fs_file_value, **ctx): + instance = self.env["test.model"].create({}) + if ctx: + instance = instance.with_context(**ctx) instance.fs_file = fs_file_value self.assertEqual(instance.fs_file.getvalue(), self.write_content) self.assertEqual(instance.fs_file.name, self.filename) def test_read(self): instance = self.env["test.model"].create( - {"fs_file": FSFileBytesIO(name=self.filename, value=self.create_content)} + {"fs_file": FSFileValue(name=self.filename, value=self.create_content)} ) info = instance.read(["fs_file"])[0] self.assertDictEqual( @@ -80,7 +82,7 @@ def test_read(self): ) def test_create_with_fsfilebytesio(self): - self._test_create(FSFileBytesIO(name=self.filename, value=self.create_content)) + self._test_create(FSFileValue(name=self.filename, value=self.create_content)) def test_create_with_dict(self): self._test_create( @@ -106,25 +108,25 @@ def test_create_in_b64(self): instance = self.env["test.model"].create( {"fs_file": base64.b64encode(self.create_content)} ) - self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertTrue(isinstance(instance.fs_file, FSFileValue)) self.assertEqual(instance.fs_file.getvalue(), self.create_content) def test_write_in_b64(self): instance = self.env["test.model"].create({"fs_file": b"test"}) instance.write({"fs_file": base64.b64encode(self.create_content)}) - self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertTrue(isinstance(instance.fs_file, FSFileValue)) self.assertEqual(instance.fs_file.getvalue(), self.create_content) def test_write_in_b64_with_specified_filename(self): self._test_write( - base64.b64encode(self.write_content), {"fs_filename": self.filename} + base64.b64encode(self.write_content), fs_filename=self.filename ) def test_create_with_io(self): instance = self.env["test.model"].create( {"fs_file": io.BytesIO(self.create_content)} ) - self.assertTrue(isinstance(instance.fs_file, FSFileBytesIO)) + self.assertTrue(isinstance(instance.fs_file, FSFileValue)) self.assertEqual(instance.fs_file.getvalue(), self.create_content) def test_write_with_io(self): @@ -132,19 +134,20 @@ def test_write_with_io(self): {"fs_file": io.BytesIO(self.create_content)} ) instance.write({"fs_file": io.BytesIO(b"test3")}) - self.assertTrue(isinstance(instance.fs_file, io.IOBase)) + self.assertTrue(isinstance(instance.fs_file, FSFileValue)) self.assertEqual(instance.fs_file.getvalue(), b"test3") def test_modify_fsfilebytesio(self): - """If you modify the content of the FSFileBytesIO using the write - method on the FSFileBytesIO object, the changes will be directly applied - and a new file in the storage must be created for the new content. + """If you modify the content of the FSFileValue, + the changes will be directly applied + and a new file in the storage must be created for the new content. """ instance = self.env["test.model"].create( - {"fs_file": FSFileBytesIO(name=self.filename, value=self.create_content)} + {"fs_file": FSFileValue(name=self.filename, value=self.create_content)} ) initial_store_fname = instance.fs_file.attachment.store_fname - instance.fs_file.write(b"new_content") + with instance.fs_file.open(mode="wb") as f: + f.write(b"new_content") self.assertNotEqual( instance.fs_file.attachment.store_fname, initial_store_fname ) From 9eb4865589531e0b20a3d566c52aaab92632b4e5 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Thu, 24 Aug 2023 12:02:49 +0000 Subject: [PATCH 03/40] [UPD] Update fs_file.pot --- fs_file/i18n/fs_file.pot | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 fs_file/i18n/fs_file.pot diff --git a/fs_file/i18n/fs_file.pot b/fs_file/i18n/fs_file.pot new file mode 100644 index 0000000000..97d9aecf30 --- /dev/null +++ b/fs_file/i18n/fs_file.pot @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fs_file +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: fs_file +#. odoo-javascript +#: code:addons/fs_file/static/src/views/fields/fsfile_field.xml:0 +#, python-format +msgid "Clear" +msgstr "" + +#. module: fs_file +#. odoo-javascript +#: code:addons/fs_file/static/src/views/fields/fsfile_field.xml:0 +#, python-format +msgid "Edit" +msgstr "" + +#. module: fs_file +#. odoo-javascript +#: code:addons/fs_file/static/src/views/fields/fsfile_field.esm.js:0 +#, python-format +msgid "The file size exceeds the maximum allowed size of %s MB." +msgstr "" + +#. module: fs_file +#. odoo-javascript +#: code:addons/fs_file/static/src/views/fields/fsfile_field.xml:0 +#: code:addons/fs_file/static/src/views/fields/fsfile_field.xml:0 +#, python-format +msgid "Upload your file" +msgstr "" + +#. module: fs_file +#. odoo-javascript +#: code:addons/fs_file/static/src/views/fields/fsfile_field.xml:0 +#, python-format +msgid "Uploading..." +msgstr "" From c9329a7256d2fa8cf4f32356e577bf9c2460996f Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 24 Aug 2023 12:05:50 +0000 Subject: [PATCH 04/40] [UPD] README.rst --- fs_file/README.rst | 203 +++++++++++++++++++++++--- fs_file/static/description/index.html | 66 +++++++-- 2 files changed, 229 insertions(+), 40 deletions(-) diff --git a/fs_file/README.rst b/fs_file/README.rst index 38929e8775..cbfb3975ff 100644 --- a/fs_file/README.rst +++ b/fs_file/README.rst @@ -1,35 +1,190 @@ -**This file is going to be generated by oca-gen-addon-readme.** +======= +Fs File +======= -*Manual changes will be overwritten.* +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -Please provide content in the ``readme`` directory: +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github + :target: https://github.com/OCA/storage/tree/16.0/fs_file + :alt: OCA/storage +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/storage-16-0/storage-16-0-fs_file + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/275/16.0 + :alt: Try me on Runbot -* **DESCRIPTION.rst** (required) -* INSTALL.rst (optional) -* CONFIGURE.rst (optional) -* **USAGE.rst** (optional, highly recommended) -* DEVELOP.rst (optional) -* ROADMAP.rst (optional) -* HISTORY.rst (optional, recommended) -* **CONTRIBUTORS.rst** (optional, highly recommended) -* CREDITS.rst (optional) +|badge1| |badge2| |badge3| |badge4| |badge5| -Content of this README will also be drawn from the addon manifest, -from keys such as name, authors, maintainers, development_status, -and license. -A good, one sentence summary in the manifest is also highly recommended. +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ +**Table of contents** -Automatic changelog generation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. contents:: + :local: -`HISTORY.rst` can be auto generated using `towncrier `_. +Usage +===== -Just put towncrier compatible changelog fragments into `readme/newsfragments` -and the changelog file will be automatically generated and updated when a new fragment is added. +The new field **FSFile** has been developed to allows you to store files +in an external filesystem storage. Its design is based on the following +principles: -Please refer to `towncrier` documentation to know more. +* The content of the file must be read from the filesystem only when + needed. +* It must be possible to manipulate the file content as a stream by default. +* Unlike Odoo's Binary field, the content is the raw file content by default + (no base64 encoding). +* To allows to exchange the file content with other systems, writing the + content as base64 is possible. The read operation will return a json + structure with the filename, the mimetype, the size and a url to download the file. -NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. -If you need to run it manually, refer to `OCA/maintainer-tools README `_. +This design allows to minimize the memory consumption of the server when +manipulating large files and exchanging them with other systems through +the default jsonrpc interface. + +Concretely, this design allows you to write code like this: + +.. code-block:: python + + from IO import BytesIO + from odoo import models, fields + from odoo.addons.fs_file.fields import FSFile + + class MyModel(models.Model): + _name = 'my.model' + + name = fields.Char() + file = FSFile() + + # Create a new record with a raw content + my_model = MyModel.create({ + 'name': 'My File', + 'file': BytesIO(b"content"), + }) + + assert(my_model.file.read() == b"content") + + # Create a new record with a base64 encoded content + my_model = MyModel.create({ + 'name': 'My File', + 'file': b"content".encode('base64'), + }) + assert(my_model.file.read() == b"content") + + # Create a new record with a file content + my_model = MyModel.create({ + 'name': 'My File', + 'file': open('my_file.txt', 'rb'), + }) + assert(my_model.file.read() == b"content") + assert(my_model.file.name == "my_file.txt") + + # create a record with a file content as base64 encoded and a filename + # This method is useful to create a record from a file uploaded + # through the web interface. + my_model = MyModel.create({ + 'name': 'My File', + 'file': { + 'filename': 'my_file.txt', + 'content': base64.b64encode(b"content"), + }, + }) + assert(my_model.file.read() == b"content") + assert(my_model.file.name == "my_file.txt") + + # write the content of the file as base64 encoded and a filename + # This method is useful to update a record from a file uploaded + # through the web interface. + my_model.write({ + 'file': { + 'name': 'my_file.txt', + 'file': base64.b64encode(b"content"), + }, + }) + + # the call to read() will return a json structure with the filename, + # the mimetype, the size and a url to download the file. + info = my_model.file.read() + assert(info["file"] == { + "filename": "my_file.txt", + "mimetype": "text/plain", + "size": 7, + "url": "/web/content/1234/my_file.txt", + }) + + # use the field as a file stream + # In such a case, the content is read from the filesystem without being + # stored in memory. + with my_model.file.open("rb) as f: + assert(f.read() == b"content") + + # use the field as a file stream to write the content + # In such a case, the content is written to the filesystem without being + # stored in memory. This kind of approach is useful to manipulate large + # files and to avoid to use too much memory. + # Transactional behaviour is ensured by the implementation! + with my_model.file.open("wb") as f: + f.write(b"content") + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +Laurent Mignon +Marie Lejeune + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-lmignon| image:: https://github.com/lmignon.png?size=40px + :target: https://github.com/lmignon + :alt: lmignon + +Current `maintainer `__: + +|maintainer-lmignon| + +This module is part of the `OCA/storage `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fs_file/static/description/index.html b/fs_file/static/description/index.html index 166f0ed9dd..cf7f727c07 100644 --- a/fs_file/static/description/index.html +++ b/fs_file/static/description/index.html @@ -3,7 +3,7 @@ - + Fs File