mostafaznv / nova-ckeditor

CkEditor 5 Field for Laravel Nova with Media & Snippet Browsers
https://mostafaznv.gitbook.io/nova-ckeditor/
MIT License
51 stars 21 forks source link

Issue with the tmp directory #81

Closed Brand3000 closed 11 months ago

Brand3000 commented 11 months ago

Hello! I came across with an issue. sys_get_temp_dir() returns a directory where my domain doesn't have access. It was /tmp My hosting provider said that I needed using the full path /var/www/site/tmp For this reason I had to add the variable in the config: 'tmpDir' => '/var/www/site/tmp', and process it in the resize function like so: $tmpDir = $config['tmpDir'] ?? sys_get_temp_dir(); $filePath = $this->makeTargetFilePath($fileName, $tmpDir); It'd be great if you add this feature in your basic installation

mostafaznv commented 11 months ago

Hi @Brand3000

You can already customize the ImageStorage. With this feature, you can override the ImageStorage and rewrite any function you want.

Here's an example:

<?php

namespace App\Helpers;

use Mostafaznv\NovaCkEdito\ImageStorager;

class MyImageStorage extends ImageStorage
{
    protected function makeTargetFilePath(string $name): string
    {    
        return public_path('tmp');
    }
}
Brand3000 commented 11 months ago

It works. Thanks!

On 4 Oct 2023, at 16:41, Mostafa Zeinivand @.***> wrote:

Hi @Brand3000 https://github.com/Brand3000 You can already customize the ImageStorage. With this https://mostafaznv.gitbook.io/nova-ckeditor/advanced-usage/customize-imagestorage feature, you can override the ImageStorage and rewrite any function you want.

Here's an example:

<?php

namespace App\Helpers;

use Mostafaznv\NovaCkEdito\ImageStorager;

class MyImageStorage extends ImageStorage { protected function makeTargetFilePath(string $name): string {
return public_path('tmp'); } } — Reply to this email directly, view it on GitHub https://github.com/mostafaznv/nova-ckeditor/issues/81#issuecomment-1746904968, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARCAHAVVUXD6PLE7A7ZAV4TX5VRRVAVCNFSM6AAAAAA5PZOKQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWHEYDIOJWHA. You are receiving this because you were mentioned.

— Vladimir, full-stack web developer @. @.> phone, viber, telegram, whatsapp: +38 050 656 45 30 https://studiobrand.net https://studiobrand.net/ - website development https://sitewill.com https://sitewill.com/ - rent a website https://www.linkedin.com/in/brand3000/ https://www.linkedin.com/in/brand3000/ , https://www.facebook.com/brand2001/ https://www.facebook.com/brand2001/ - get in touch

Brand3000 commented 11 months ago

Thank you