Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
invenio-previewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fdm
invenio-previewer
Commits
9f973f52
Unverified
Commit
9f973f52
authored
1 year ago
by
Nicola Tarocco
Browse files
Options
Downloads
Patches
Plain Diff
csv: re-add max filesize check
parent
00ae43e2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
invenio_previewer/config.py
+1
-1
1 addition, 1 deletion
invenio_previewer/config.py
invenio_previewer/extensions/csv_papaparsejs.py
+12
-3
12 additions, 3 deletions
invenio_previewer/extensions/csv_papaparsejs.py
with
13 additions
and
4 deletions
invenio_previewer/config.py
+
1
−
1
View file @
9f973f52
...
...
@@ -21,7 +21,7 @@ PREVIEWER_CHARDET_CONFIDENCE = 0.9
"""
Confidence threshold for character encoding detection by `cchardet`.
"""
PREVIEWER_MAX_FILE_SIZE_BYTES
=
1
*
1024
*
1024
"""
Maximum file size in bytes for JSON/XML files.
"""
"""
Maximum file size in bytes for JSON/XML
/CSV
files.
"""
PREVIEWER_MAX_IMAGE_SIZE_BYTES
=
0.5
*
1024
*
1024
"""
Maximum file size in bytes for image files.
"""
...
...
This diff is collapsed.
Click to expand it.
invenio_previewer/extensions/csv_papaparsejs.py
+
12
−
3
View file @
9f973f52
...
...
@@ -15,11 +15,20 @@ from ..proxies import current_previewer
previewable_extensions
=
[
"
csv
"
,
"
dsv
"
]
def
validate_csv
(
file
):
"""
Return dialect information about given csv file.
"""
max_file_size
=
current_app
.
config
.
get
(
"
PREVIEWER_MAX_FILE_SIZE_BYTES
"
,
10
*
1024
*
1024
)
is_size_valid
=
file
.
size
<=
max_file_size
return
is_size_valid
def
can_preview
(
file
):
"""
Determine if the given file can be previewed.
"""
if
file
.
is_local
()
and
file
.
has_extensions
(
"
.csv
"
,
"
.dsv
"
):
return
True
return
False
return
(
file
.
is_local
()
and
file
.
has_extensions
(
"
.csv
"
,
"
.dsv
"
)
and
validate_csv
(
file
)
)
def
preview
(
file
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment