diff --git a/invenio.cfg b/invenio.cfg index a0741181f..55c853d89 100644 --- a/invenio.cfg +++ b/invenio.cfg @@ -1046,6 +1046,9 @@ APP_RDM_IDENTIFIER_SCHEMES_UI = { RECORDS_RESOURCES_ALLOW_EMPTY_FILES = False """Disable empty files for Zenodo.""" +RECORDS_RESOURCES_USE_STAGED_TRANSFER = True +"""Use staged transfer for file uploads.""" + IIIF_PROXY_CLASS = IIPServerProxy """IIIF proxy class for IIIF server.""" diff --git a/site/zenodo_rdm/permissions.py b/site/zenodo_rdm/permissions.py index 678c1be7e..9a637d334 100644 --- a/site/zenodo_rdm/permissions.py +++ b/site/zenodo_rdm/permissions.py @@ -25,7 +25,10 @@ SystemProcess, ) from invenio_records_resources.services.files.generators import IfTransferType -from invenio_records_resources.services.files.transfer import LOCAL_TRANSFER_TYPE +from invenio_records_resources.services.files.transfer import ( + LOCAL_STAGED_TRANSFER_TYPE, + LOCAL_TRANSFER_TYPE, +) from invenio_users_resources.services.permissions import UserManager from .generators import ( @@ -114,16 +117,19 @@ class ZenodoRDMRecordPermissionPolicy(RDMRecordPermissionPolicy): can_draft_set_content_files = [ # review is the same as create_files IfTransferType(LOCAL_TRANSFER_TYPE, can_review), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_review), SystemProcess(), ] can_draft_get_content_files = [ # preview is same as read_files IfTransferType(LOCAL_TRANSFER_TYPE, can_draft_read_files), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_draft_read_files), SystemProcess(), ] can_draft_commit_files = [ # review is the same as create_files IfTransferType(LOCAL_TRANSFER_TYPE, can_review), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_review), SystemProcess(), ] can_draft_update_files = can_review @@ -208,6 +214,7 @@ class ZenodoRDMRecordPermissionPolicy(RDMRecordPermissionPolicy): # note: even though this is closer to business logic than permissions, # it was simpler and less coupling to implement this as permission check IfTransferType(LOCAL_TRANSFER_TYPE, can_read_files), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_read_files), SystemProcess(), ] @@ -216,16 +223,19 @@ class ZenodoRDMRecordPermissionPolicy(RDMRecordPermissionPolicy): can_draft_media_read_files = can_draft_read_files can_draft_media_set_content_files = [ IfTransferType(LOCAL_TRANSFER_TYPE, can_draft_media_create_files), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_draft_media_create_files), SystemProcess(), ] can_draft_media_get_content_files = [ # preview is same as read_files IfTransferType(LOCAL_TRANSFER_TYPE, can_get_content_files), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_get_content_files), SystemProcess(), ] can_draft_media_commit_files = [ # review is the same as create_files IfTransferType(LOCAL_TRANSFER_TYPE, can_draft_media_create_files), + IfTransferType(LOCAL_STAGED_TRANSFER_TYPE, can_draft_media_create_files), SystemProcess(), ] can_draft_media_update_files = can_draft_media_create_files