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

Constrain file sizes #50

Merged
merged 9 commits into from
Mar 20, 2024
Merged

Constrain file sizes #50

merged 9 commits into from
Mar 20, 2024

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Mar 20, 2024

Closes #49

@ccurme ccurme changed the title (WIP) Constrain file sizes Constrain file sizes Mar 20, 2024
@ccurme ccurme requested review from eyurtsev and bracesproul March 20, 2024 19:32
file_data = data.read()
mimetype = _guess_mimetype(file_data)
file_name = data.name

if mimetype == "application/pdf":
number_of_pages = _get_pdf_page_count(file_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we fail or extract from first few pages what do you think is more intuitive?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(This is OK for now obviously)

@@ -112,7 +112,7 @@ async def test_extract_from_file() -> None:

# We'll use multi-form data here.
# Create a named temporary file
with tempfile.NamedTemporaryFile(mode="w+t", delete=False) as f:
with tempfile.NamedTemporaryFile(mode="w+t", delete=True) as f:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest separate unit test since it's getting pretty long on one api test

@ccurme ccurme merged commit fe57149 into main Mar 20, 2024
6 checks passed
@ccurme ccurme deleted the cc/file_sizes branch March 20, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to limit file size + number of pages for extraction H
2 participants