-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
files: add file format detection on file commit
* this functionality uses a tool called siegfried https://github.com/richardlehane/siegfried
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
invenio_records_resources/services/files/components/filetype.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2024 TU Wien. | ||
# | ||
# Invenio-Records-Resources is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
|
||
"""Service component for detecting file types.""" | ||
|
||
from ...uow import TaskOp | ||
from ..tasks import detect_file_type | ||
from .base import FileServiceComponent | ||
|
||
|
||
class FileTypeDetectionComponent(FileServiceComponent): | ||
"""Service component for detecting file types.""" | ||
|
||
def commit_file(self, identity, id, file_key, record): | ||
"""Detect the file format as soon as the file has been committed.""" | ||
self.uow.register(TaskOp(detect_file_type, str(record.bucket.id), file_key)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters