Spatie Media Library File Upload replacing every uploaded file
Hello, I have created a custom action for a file upload to my table, but when I upload a file it replaces all the already uploaded files. This hasn't been happening before.
After going through the code I found out the
deleteAbandonedFiles()
method in the plugin, this gets called in the saveRelationshipUsing()
method. It looks to me that only the uploaded file UUID gets added to the state so the rest of the files get deleted. But I'm not sure how to fix this.
My custom action:
12 Replies
saveRelationshipsUsing()
in SpateMiediaLibraryFileUpload.php:91
:
deleteAbondanodedFiles()
in SpatieMediaLibraryFileUpload.php:189
:
it should be multiple() if you want multiple files to be stored at once
Yeah but it still replaces all my uploaded files
Let me add some screenshots
A folder to which I uploaded 17 files.
this is what it looks like in my "file viewer"
are the 17 files populating into your file upload when the form loads
Not sure how can I check that?
I thank that is the issue
open the file upload
make sure theyre all there
then you can add new ones, delete, etc
This is what I see when I open the file upload, so no they're not populating
How can I make sure they do?
is that what you want though
maybe you just extend the field class and remove the bit that deletes abandoned files
yeah I do this:
and it seems to work