Add 'delete all' button to (Multi)FileField

I would like to delete all files in the “Upload files” area automatically via a button. The reason for this is that I want to be able to upload new photos again in order to insert them into a new report.

Currently “files_picture” is deleted and the content in “MultiFileField” remains. I have not found anything helpful in the documentation and manually deleting all images is not an option in the long term.

Here is the view window “upload files”:

Here is the Code:

files_picture = MultiFileField('Upload files', file_types=['.png', '.jpg', '.jpeg'], max_size=499_000_000)
delete_files_picture = SetParamsButton('Bilder löschen', method='delete_uploaded_pictures')

def delete_uploaded_pictures(self, params, **kwargs):
        uploaded_files = params.files_picture
        if uploaded_files:
            uploaded_files.clear()

        return SetParamsResult({
            "files_picture": uploaded_files,
            
        })

Hi Johannes,

Welcome to the forum, thanks for posting!!

That’s a very interesting issue you’re raising there. There’s always a way to do everything, in this case I suspect your solutions has to lie somewhere in using a few API calls to remove the files. Our API documentation shows the different functionalities.

Just so I can maybe give you a working example: what app type are you using? and are there multiple FileFields in this entity?

Hi Daniel,

the app type is editor. Yes there are two FileFields. The first is for uploading a Word template and the second is for uploading several images.

Okay, after discussing it with our platform team we decided that rather than looking for a very hacky (and most likely quite unstable) workaround, we’d be better off just building this into the product itself.
Hence I will relabel this topic to a Feature Request and I’ll also add it to our internal issue tracker.

We’ll then keep you updated on the progress in this post