Closed ERosendo closed 1 year ago
Thank you! @mlissner I've applied the requested changes.
We can also use the FileExtensionValidator to limit the input of this new service. This class from django.core.validators
checks the extension of the file that's been uploaded and raises a ValidationError if the extension is not allowed. If We use this validator class, the ThumbnailForm
will look like this:
class ThumbnailForm(forms.Form):
file = forms.FileField(
label="document",
required=True,
validators=[FileExtensionValidator(["pdf"])],
)
max_dimension = forms.IntegerField(label="max-dimension", required=False)
pages = forms.Field(label="pages", required=False)
Let me know what you think.
Sure, might as well use the validator, why not.
The rest looks good. If you want to do the validator, go for it. If you want to add the zip bomb protection, go for it. Whatever you do, please merge when you're happy.
This PR adds support generating multiple thumbnails from a PDF and resolves https://github.com/freelawproject/doctor/issues/126.
This new service returns a .zip file containing thumbnails for each page requested.