You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've seen it mentioned a few times, but here i am.
I am aware of feature to "rename" $media->file_name, but this is for After the saving on Disk and all the manipulations.
This doesn't work with \Spatie\MediaLibrary\FileAdder\FileAdder objects, that you "actually" get after $model->addMedia($request->file('contents'))
Also, as some ppl noticed: the copyToMediaLibrary does have an optional $subDirectory parameter. However, I haven't found a way(in the docs) to set this parameter anywhere.
Questions are:
how to set targetFilename Prior the saveOnDisc?
how to set $subDirectory (but this could break compatibility.. as file_name should also be updated)?
if media->file_name will have sub-directories(slashes in file_name) will it break anything?
The text was updated successfully, but these errors were encountered:
The above method only changes the name of the underlying file. If you want to change the name of the media object as well you can do this:
$newsItem
->addMedia('test.txt')
->usingName('some other name')
->usingFileName('othertext.txt')
->toMediaLibrary();
There is currently no support for using subdirectories. The copyToMediaLibrary-function is used internally by the package. There is an extra parameter there so the package can handle storing conversions.
I haven't tested using slashes in the filename, it might work for now, but I don't recommend it.
I've seen it mentioned a few times, but here i am.
I am aware of feature to "rename"
$media->file_name
, but this is for After the saving on Disk and all the manipulations.This doesn't work with
\Spatie\MediaLibrary\FileAdder\FileAdder
objects, that you "actually" get after$model->addMedia($request->file('contents'))
Also, as some ppl noticed: the
copyToMediaLibrary
does have an optional $subDirectory parameter. However, I haven't found a way(in the docs) to set this parameter anywhere.Questions are:
The text was updated successfully, but these errors were encountered: