mirror of
https://github.com/suitenumerique/drive.git
synced 2026-08-17 20:15:40 +02:00
✨(backend) allow grist file upload
The .grist extension was already in FILE_EXTENSIONS_ALLOWED but upload failed at MIME type validation because python-magic detects grist files as application/vnd.sqlite3.
This commit is contained in:
@@ -14,6 +14,7 @@ and this project adheres to
|
||||
- ✨(backend) add recursive folder export as ZIP archive
|
||||
- ✨(frontend) add folder export action
|
||||
- ✨(backend) background conversion of legacy Office files
|
||||
- ✨(backend) allow grist file upload
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -95,6 +95,30 @@ def test_api_item_upload_ended_on_wrong_upload_state():
|
||||
}
|
||||
|
||||
|
||||
def test_api_item_upload_ended_success_grist_file():
|
||||
"""Upload a .grist file (SQLite format) should succeed."""
|
||||
user = factories.UserFactory()
|
||||
client = APIClient()
|
||||
client.force_login(user)
|
||||
|
||||
item = factories.ItemFactory(type=ItemTypeChoices.FILE, filename="my_table.grist")
|
||||
factories.UserItemAccessFactory(item=item, user=user, role="owner")
|
||||
|
||||
# Minimal valid SQLite database header (100 bytes).
|
||||
sqlite_header = b"SQLite format 3\x00\x10\x00\x01\x01\x00\x40\x20\x20" + b"\x00" * 76
|
||||
default_storage.save(item.file_key, BytesIO(sqlite_header))
|
||||
|
||||
with mock.patch.object(malware_detection, "analyse_file") as mock_analyse_file:
|
||||
response = client.post(f"/api/v1.0/items/{item.id!s}/upload-ended/")
|
||||
|
||||
mock_analyse_file.assert_called_once_with(item.file_key, item_id=item.id)
|
||||
assert response.status_code == 200
|
||||
|
||||
item.refresh_from_db()
|
||||
assert item.upload_state == ItemUploadStateChoices.ANALYZING
|
||||
assert item.mimetype == "application/vnd.sqlite3"
|
||||
|
||||
|
||||
def test_api_item_upload_ended_success():
|
||||
"""
|
||||
Users should be able to end an upload on items that are files and in the UPLOADING upload state.
|
||||
|
||||
@@ -640,6 +640,7 @@ class Base(Configuration):
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||
"application/vnd.palm",
|
||||
"application/vnd.realvnc.bed",
|
||||
"application/vnd.sqlite3",
|
||||
"application/vnd.sun.xml.calc",
|
||||
"application/vnd.sun.xml.calc.template",
|
||||
"application/vnd.sun.xml.draw",
|
||||
@@ -668,6 +669,7 @@ class Base(Configuration):
|
||||
"application/x-rar-compressed",
|
||||
"application/x-research-info-systems",
|
||||
"application/x-sh",
|
||||
"application/x-sqlite3",
|
||||
"application/x-sql",
|
||||
"application/x-subrip",
|
||||
"application/x-tar",
|
||||
|
||||
Reference in New Issue
Block a user