filestorage

This commit is contained in:
Egor Matveev
2021-11-11 11:47:06 +03:00
parent a8111c45e9
commit edb58e23a3
22 changed files with 237 additions and 93 deletions

14
Main/models/mixins.py Normal file
View File

@@ -0,0 +1,14 @@
from SprintLib.utils import get_bytes, write_bytes, delete_file
class FileStorageMixin:
@property
def text(self):
return get_bytes(self.fs_id).decode("utf-8")
def write(self, bytes):
self.fs_id = write_bytes(bytes)
self.save()
def remove_from_fs(self):
delete_file(self.fs_id)