Change file storage location

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • rabii
    replied
    Here is how you can do it in an upgrade safe way:

    1 - create custom/Espo/Custom/Resourcs/metadata/app/fileStorage.json
    PHP Code:
    {
        
    "implementationClassNameMap": {
             
    "EspoUploadDir""\\Espo\\Custom\\Core\\FileStorage\\Storages\\EspoUploadDir"    
        
    }
    }
    ​ 

    2 - create custom/Espo/Custom/Core/FileStrage/Storages/EspoUploadDir.php
    PHP Code:
    <?php

    namespace Espo\Custom\Core\FileStorage\Storages;

    use 
    \Espo\Entities\Attachment;
    use 
    \Espo\Core\Exceptions\Error;

    class 
    EspoUploadDir extends Espo\Core\FileStorage\Storages\EspoUploadDir
    {
        protected function 
    getFilePath(Attachment $attachment)
        {
            
    $sourceId $attachment->getSourceId();
            return 
    'crm/storageunit/' $sourceId// HERE YOUR CUSTOM PATH
        
    }
    }

    I hope this helps
    Last edited by rabii; 01-06-2025, 01:34 PM.

    Leave a comment:


  • rabii
    replied
    You need to implement a custom storage check this out https://docs.espocrm.com/development...-file-storage/

    Leave a comment:


  • Zoltar
    started a topic Change file storage location

    Change file storage location

    Hello,


    Is it possible to change location for KB & Document uploads?

    Any time you upload a file or picture I'd like to direct these to a specific drive\storage array.

    I see some of it is stored in "/data/upload"

    I found this in the Config file, but changing it doesn't seem to do anything:

    'defaultFileStorage' => 'EspoUploadDir'


    With appreciation,
    Justin
Working...