form icon indicating copy to clipboard operation
form copied to clipboard

Delete uploaded resource after failed validation

Open fdchriswaechter opened this issue 1 year ago • 1 comments

Problem: When a file is uploaded using the FormUpload element, it is immediately saved to the resource collection upon form submission. However, if the file is later deemed invalid, it still occupies server storage, leading to unnecessary and potentially significant consumption of storage space.

Implementation: The \Neos\Form\Validation\FileTypeValidator now utilizes an injected resource manager. If a file fails validation, the resource manager deletes the corresponding file and entry in the DB, preventing invalid files from being permanently stored and conserving server storage space.

fdchriswaechter avatar Aug 26 '24 16:08 fdchriswaechter

Thank you for this fix! I understand the problem and there might not be a good place to fix this, my only worry would be that this deletes the file in some cases but not in others (for example if the validation fails on something else and no resubmit happens).

I'll have a closer look.

kitsunet avatar Aug 27 '24 07:08 kitsunet