ckan / ckanext-validation

CKAN extension for validating Data Packages using Table Schema.
MIT License
30 stars 33 forks source link

Fix Upload Field Condition #96

Open JVickery-TBS opened 9 months ago

JVickery-TBS commented 9 months ago

fix(dev): FieldStorage support;

CKANAPI uses cgi.FieldStorage (https://github.com/ckan/ckanapi/blob/master/ckanapi/localckan.py#L67) as to not require a lot of dependencies. Related issue on cgi.FieldStorage: https://bugs.python.org/issue19097

To support all py versions and cgi dependency versions, just checking for the file attribute might be good enough?

ThrawnCA commented 9 months ago

We've seen situations before where the FileStorage object exists but is blank, and it's necessary to further check that it has a truthy filename.

JVickery-TBS commented 9 months ago

@ThrawnCA reckon I should add the filename attribute condition after the new file one? Or just replace the new file condition with filename?

ThrawnCA commented 9 months ago

Offhand I'm not sure whether testing file and testing filename are interchangeable.

JVickery-TBS commented 9 months ago

@ThrawnCA good enough for me! haha, I have added the filename condition in the case that the file attribute of a File like object is empty, but there is a filename. Should still get queued for validation and then the validation will fail and tell the user that their file is empty. This make sense to me