oarepo_config.files
oarepo_config.files
Configuration for record files and upload quotas.
configure_files(max_file_size: int = 1 * 10 ** 9, max_files_count: int = 100, max_total_size: int = 5 * 10 ** 9, allow_metadata_only_records: bool = True, allow_empty_files: bool | None = None, file_modification_grace_period: timedelta = timedelta(days=45), allow_immediate_file_modification: bool = True, allow_immediate_quota_increase: bool = True, max_additional_quota_size: int = 0, allow_archive_download: bool = True, max_archive_download_size: int | None = None) -> None
Set up file upload quotas and file-related toggles.
Controls how many files users may attach to a record deposition, how large each individual file may be, the total storage budget for the deposition, whether a deposition can be published without any files at all, and whether uploaded files may have zero bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_file_size
|
int
|
Maximum size of a single uploaded file in bytes.
Defaults to 1 GB ( |
1 * 10 ** 9
|
max_files_count
|
int
|
Maximum number of files allowed per record
deposition. Defaults to |
100
|
max_total_size
|
int
|
Maximum combined size of all files in a single
record deposition, in bytes. Defaults to 5 GB
( |
5 * 10 ** 9
|
allow_metadata_only_records
|
bool
|
When |
True
|
allow_empty_files
|
bool | None
|
When |
None
|
file_modification_grace_period
|
timedelta
|
Grace period after a record is
published during which its files can still be modified without
creating a new version. Checked at publish time. Defaults to
45 days ( |
timedelta(days=45)
|
allow_immediate_file_modification
|
bool
|
When |
True
|
allow_immediate_quota_increase
|
bool
|
When |
True
|
max_additional_quota_size
|
int
|
Additional quota users/admins may grant on top of the default record quota. Defaults to 0. |
0
|
allow_archive_download
|
bool
|
Whether all files of a record can be
downloaded at once as a single ZIP archive ("Download all").
The archive is assembled on the fly by a web worker, which
stays busy for the whole download. Defaults to |
True
|
max_archive_download_size
|
int | None
|
Largest total size of a record's files,
in bytes, for which the "Download all" archive is still
offered; larger records only offer per-file downloads. |
None
|
Invenio configuration variables set:
RDM_FILES_DEFAULT_MAX_FILE_SIZE- backend limit on the size of a single file.RDM_FILES_DEFAULT_QUOTA_SIZE- backend limit on the total size of all files in a record deposition.RDM_RECORDS_MAX_FILES_COUNT- backend limit on the number of files per record.RDM_ALLOW_METADATA_ONLY_RECORDS- whether metadata-only records are allowed.RECORDS_RESOURCES_ALLOW_EMPTY_FILES- whether zero-byte files may be uploaded.RDM_FILE_MODIFICATION_PERIOD- time window after record creation during which modified files may be published.RDM_IMMEDIATE_FILE_MODIFICATION_ENABLED- whether published files may be edited immediately; set toallow_immediate_file_modification.RDM_IMMEDIATE_FILE_MODIFICATION_POLICIES- ordered list of policies deciding who may edit published files immediately (only set whenallow_immediate_file_modificationisTrue).RDM_IMMEDIATE_QUOTA_INCREASE_ENABLED- whether users may immediately raise a draft's quota; set toallow_immediate_quota_increase.RDM_IMMEDIATE_QUOTA_INCREASE_POLICIES- ordered list of policies deciding who may raise a draft's quota (only set whenallow_immediate_quota_increaseisTrue).APP_RDM_DEPOSIT_FORM_QUOTA- deposit-form UI quota object withmaxFilesandmaxStorage.FILES_REST_DEFAULT_MAX_FILE_SIZEandFILES_REST_DEFAULT_QUOTA_SIZE- fallback variables used by the lower-level file storage layer.RDM_FILES_DEFAULT_MAX_ADDITIONAL_QUOTA_SIZE- themax_additional_quota_sizeabove.RDM_ARCHIVE_DOWNLOAD_ENABLED- whether the "Download all" archive is available.RECORDS_RESOURCES_ARCHIVE_DOWNLOAD_MAX_SIZE- total size limit for the "Download all" archive.
Example
# Use the default file quotas and toggles. All parameters below
# match the helper's built-in defaults and are shown explicitly
# for reference; they can be omitted when calling the helper.
config.configure_files(
max_file_size=1 * 10**9,
max_files_count=100,
max_total_size=5 * 10**9,
allow_metadata_only_records=True,
)
Source code in oarepo_config/files.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |