Sopamo / laravel-filepond

Laravel backend module for filepond uploads
MIT License
204 stars 54 forks source link

Fix error on delete method #53

Closed ryanito closed 2 years ago

ryanito commented 3 years ago

This PR fixes the delete method of the controller to correctly delete the folder for the uploaded file (closes #41). As mentioned in #42 it uses Laravel's Storage feature instead of local disk.


public function delete(Request $request)
    {
        $absolutePathToFile = $this->filepond->getPathFromServerId($request->getContent());
        $storagePathToFile = strstr($absolutePathToFile, config('filepond.temporary_files_path', 'storage/app'));
        $storagePathToFolder = dirname($storagePathToFile);
        if (Storage::disk(config('filepond.temporary_files_disk', 'local'))->deleteDirectory($storagePathToFolder)) {
            return Response::make('', 200, [
                'Content-Type' => 'text/plain',
            ]);
        }

        return Response::make('', 500, [
            'Content-Type' => 'text/plain',
        ]);
    }```
Pezhvak commented 2 years ago

@Sopamo would you please merge this?

patimio66 commented 2 years ago

@Sopamo please merge this pr.

Sopamo commented 2 years ago

@ryanito thanks for your contribution! Could you please update your PR to work with the latest V1 release?

ryanito commented 2 years ago

@ryanito thanks for your contribution! Could you please update your PR to work with the latest V1 release?

All done!

Sopamo commented 2 years ago

Thanks for your contribution!