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

QSTN: Is it possible to validate files from request #85

Closed
William-Depix opened this issue Aug 24, 2023 · 7 comments
Closed

QSTN: Is it possible to validate files from request #85

William-Depix opened this issue Aug 24, 2023 · 7 comments

Comments

@William-Depix
Copy link

Is it possible to validate uploaded files? For example, checking how many files are being uploaded in the request, what are their file types and the files' size.

I have some images appended in the form data to pass into the request. Is there any way to validate their amount, file types and file size?

Thank you!

@d-ganchar
Copy link
Owner

@William-Depix Hello. Thank you for the question.
Сurrently no ( But the idea is great. I'll be very busy for a couple of months and I have no opportunity to implement this sooner. Sorry 😔

You can add functionality if you need it faster. But we need to think about the format.

@d-ganchar d-ganchar added this to the 4.3.0 milestone Aug 24, 2023
@William-Depix
Copy link
Author

Got it. Thanks for the info!

@d-ganchar
Copy link
Owner

@William-Depix, @LostInDarkMath hey! I'm thinking about the format and wanted to know your vision.
So here is an example for multiple uploading:

@app.route('/files', methods=['POST'])
@validate_params(
    FileChain(
        mime_types=['application/pdf', 'image/jpeg'], 
        max_size=1024 * 1024, 
        max_files=3,          
        name_pattern=r'^....$' # optional
    )
)

Validation by file names:

@app.route('/files', methods=['POST'])
@validate_params(
    File(
        mime_type='application/pdf',
        max_size=1024 * 1024,
        name='document',
    ),
    File(
        mime_type='image/jpeg',
        max_size=1024 * 1024,
        name='photo',
    )
)

Any suggestions? Wishes?

@LostInDarkMath
Copy link
Contributor

I think that the mime_type should be an array because in most cases, multiple mime types are allowed.

d-ganchar added a commit that referenced this issue Dec 11, 2023
d-ganchar added a commit that referenced this issue Dec 12, 2023
d-ganchar added a commit that referenced this issue Dec 12, 2023
@d-ganchar
Copy link
Owner

@William-Depix published. I'll update docs later. I'm really very busy

@d-ganchar d-ganchar added the doc label Dec 12, 2023
@William-Depix
Copy link
Author

This looks exactly what I need! Thanks a lot!

@d-ganchar
Copy link
Owner

rules
release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants