Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSV max filesize check (#190) #191

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion invenio_previewer/extensions/csv_papaparsejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@

def can_preview(file):
"""Determine if the given file can be previewed."""
return file.is_local() and file.has_extensions(".csv", ".dsv")
max_file_size = current_app.config.get(
Copy link
Member

@alejandromumo alejandromumo Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, would it make sense to have a validator function (i.e. validate_csv) to separate concerns?

This is done for other extensions (e.g. json)

"PREVIEWER_MAX_FILE_SIZE_BYTES", 1 * 1024 * 1024
)
return (
file.is_local()
and file.has_extensions(".csv", ".dsv")
and file.size <= max_file_size
)


def preview(file):
Expand Down