spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.07k forks source link

[BUG] Temporary files uploads to permanent place "disk", not in the "temporary_directory_path" #3016

Closed flamreal closed 1 year ago

flamreal commented 2 years ago

Bug report

What I did

I just reinstall clear latest version of laravel project and medialibrary PRO, then I try to upload and attach media file to my model by blade(livewire) component. I did it step by step by instructions.

What I expected to happen

I expect media file will put to media-library/temp after first uploading (and before attach file and store model). My medialibrary config:

'disk_name' => env('MEDIA_DISK', 'media')
'temporary_directory_path' => null // (it means storage_path('media-library/temp') by default, and if I set path manually it has no effect)

Form component: <x-media-library-attachment name="media" />

And after, only when I attach file to model

        \App\Models\User::saving(function($entry) {
            $entry->syncFromMediaLibraryRequest($this->crud->getRequest()->media)
                ->toMediaCollection('photo');
        });

the file will be replaced to a permanent location (media disk)

What happened

BUT When I select image for upload, it immediately uploads to "media" disk, NOT to temporary directory! For example file creats in this path: ../storage/app/public/media/269ee9c8ab9dc1878f7b8f2968ae9675/76da0d56b77a20d58b52b1bc48588f33screen-shot-123449-preview.jpg and EMPTY folder ../storage/media-library/temp creats. Temporary fields in database creats too.

When I try to attach media to model while storing (look code above), It leads to fatal error: fopen(/../storage/media-library/temp/QAd0KG0Z9nQ3utTTfZVHEmV7cKaf7u1n//269ee9c8ab9dc1878f7b8f2968ae9675.jpg): Failed to open stream: No such file or director

Because file isn't placed on this path...

Can you explain why library uploads file to one directory, and then try to find this file in another directory?! I think it is bug, because it leads to fatal error and unexpected behavior.

Laravel, PHP, medialibrary versions

PHP 8.0.22 Laravel v9.27.0 Medialibrary 10.4.4 Medialibrary PRO 2.5.4

flamreal commented 2 years ago

Guys, I can't continue do anything with this error =\ Any advices? may be downgrade to any stable version? wich one is stable enough?

fredsal commented 2 years ago

Here not everybody has the PRO version, only public media library, so you have to contact author for PRO support

flamreal commented 2 years ago

Guys! fix this please...

The issue summery is:

It is paid extension. Where is your support? I think it is simply for you to fix this. Howewer, more then two months passed

tomredhot commented 1 year ago

Hi. Same problem here o/ image image We can see here, that the folder with uuid name stay outside the temporary folder.

spatie-bot commented 1 year ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

AndreiBil commented 1 year ago

Anyone got a solution for this? Dealing with exactly the same issue

gavinhoward100 commented 1 year ago

Same issue. Won't be renewing this licence.