oneduo / nova-file-manager

The most advanced File Manager for Laravel Nova, feature rich and robust build.
https://oneduo.github.io/nova-file-manager/
MIT License
138 stars 38 forks source link

fix S3, PutObject for new folder creation #413

Closed KarimiCosalux closed 3 months ago

mikaelpopowicz commented 3 months ago

Hi @KarimiCosalux

The issue you are trying to resolve with you PR can be handled in a different way. Also the controllers of the package can't hold your specific logic.

You may want to configure the tool or the field to resolve the filesystem depending of your needs. According to the documentation you can use an on-demand filesystem.

// app/Nova/AResource.php

use Oneduo\NovaFileManager\FileManager;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\Facades\Storage;
use Laravel\Nova\Http\Requests\NovaRequest;

class AResource extends Resource
{
    // ...

    public function fields(NovaRequest $request): array
    {
        return [
            // ... any other fields
            FileManager::make(__('Attachments'), 'attachments')
                ->filesystem(function (NovaRequest $request): string|Filesystem {
                    // create a filesystem on user basis
                    $config = $request->user()->location->storage()->getConfig();
                    return Storage::build([
                        'driver' => $config['driver'],
                        'root' => $config['root'],
                        'url' => config('app.url').$config['url'],
                    ]);
                }),
        ];
    }
}

Of course you'll need to adapt this code to your needs.

Hope this will help you.

All the best.