#preserveFilenames() not working with SpatieMediaLibraryFileUpload

11 messages · Page 1 of 1 (latest)

tawdry knoll
#

Hi, I'm using the SpatieMediaLibraryFileUpload in a Form Builder. The docs say: "You may use the field in the same way as the original file upload field", however I can't get preserveFilenames() to work. The uploaded files are always renamed - the instruction seems to get ignored completely. Is there anything I'm missing?

blissful nexusBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

limber barn
#

Try placing it at the end of the field definition

tawdry knoll
visual path
#

Not sure whether that method works on with SpatieFileUpload since Spatie handles the upload and storage and not Filament

tawdry knoll
limber barn
#

Question.. is this is the download or the storage?

#

I am using this perfectly well:

SpatieMediaLibraryFileUpload::make('document')
    ->hiddenLabel()
    ->disk('s3_data')
    ->collection('documents')
    ->downloadable()
    ->openable()
    ->visibility('private')
    ->acceptedFileTypes(['application/vnd.openxmlformats-officedocument.wordprocessingml.document'])
    ->preserveFilenames(),
tawdry knoll
limber barn
tawdry knoll
# limber barn Where are you storing it? That stores correctly in storage for me.

I tested different disks, but the result is always the same. I also tried using the documented method for custom names and then just returning the original name in it, but this also doesn't change anything: ->getUploadedFileNameForStorageUsing( fn(TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName()), )