diff --git a/seatable_api/date_utils.py b/seatable_api/date_utils.py index a1cdfb9..621c6db 100644 --- a/seatable_api/date_utils.py +++ b/seatable_api/date_utils.py @@ -226,6 +226,13 @@ def between(cls, start, end, include_last=False): class DateUtils(object): + @classmethod + def utcnow(cls): + now = datetime.datetime.now() + utc_timezone = datetime.timezone.utc + isoformat_timestr = now.astimezone(utc_timezone).isoformat() + return isoformat_timestr + def _isoformat(self, d, format_str="%Y-%m-%d"): if not isinstance(d, (datetime.date, datetime.datetime)): raise ValueError('datetime type error') diff --git a/seatable_api/main.py b/seatable_api/main.py index ad15867..3a1adff 100644 --- a/seatable_api/main.py +++ b/seatable_api/main.py @@ -15,6 +15,7 @@ from .socket_io import SocketIO from .query import QuerySet from .utils import convert_db_rows +from .date_utils import dateutils def parse_headers(token): @@ -1005,7 +1006,8 @@ def upload_bytes_file(self, name, content: bytes, relative_path=None, file_type= 'type': file_type, 'size': d.get('size'), 'name': d.get('name'), - 'url': url + 'url': url, + 'upload_time': dateutils.utcnow() } @check_auth @@ -1050,7 +1052,8 @@ def upload_local_file(self, file_path, name=None, relative_path=None, file_type= 'type': file_type, 'size': d.get('size'), 'name': d.get('name'), - 'url': url + 'url': url, + 'upload_time': dateutils.utcnow() } @check_auth