Merge pull request #75 from fabrixxm/fix/73

Fix uploading attachments
This commit is contained in:
Thomas Sileo 2020-03-27 12:26:44 +01:00 committed by GitHub
commit ed12d8fa01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ from datetime import timedelta
from datetime import timezone
from functools import wraps
from io import BytesIO
from shutil import copyfileobj
from typing import Any
from typing import List
@ -586,7 +587,8 @@ def api_new_note() -> _Response:
file = request.files[f]
rfilename = secure_filename(file.filename)
with BytesIO() as buf:
file.save(buf)
# bypass file.save(), because it can't save to a file-like object
copyfileobj(file.stream, buf, 16384)
oid = MEDIA_CACHE.save_upload(buf, rfilename)
mtype = mimetypes.guess_type(rfilename)[0]