Announcement

Collapse
No announcement yet.

Upload all files to an object store

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I see the release is live and the upload feature is listed in the Github release notes. Thanks for your hard work.

    Comment


    • #17
      yurikuzn,

      Could you please explain how to use the file storage manager feature? I would like to upload files to S3 or Dropbox, but I don't understand if that's possible or how to get started.

      Comment


      • huscmk
        huscmk commented
        Editing a comment
        That would indeed be an excellent plus-value if we could externalize media files to Amazon S3 as it would mean no more storage issues on the servers running espocrm.

        As I understand, there is now a framework with a storage manager that still needs to get a wrapper for S3 (or any other object storage with an API) but it seems hard to do by the look to that code only as it needs a quite good understanding of how media management is done in espocrm.

        Anyone who could help with the task ?

    • #18
      1. In data/config.php need to add parameter 'defaultFileStorage' => 'AmazonS3'


      2. Create custom/Espo/Custom/Resources/metadata/app/fileStorage.json with the following content
      PHP Code:
      {
          
      "implementationClassNameMap": {
              
      "AmazonS3""\\Espo\\Custom\\Core\\FileStorage\\Storages\\AmazonS3"
          
      }


      3. Create file custom/Espo/Custom/Core/FileStorage/Storages/AmazonS3.php

      PHP Code:
      <?php

      namespace Espo\Custom\Core\FileStorage\Storages;

      use \
      Espo\Entities\Attachment;

      use \
      Espo\Core\Exceptions\Error;

      class 
      AmazonS3 extends \Espo\Core\FileStorage\Storages\Base
      {
          protected 
      $dependencyList = ['fileManager''config'];

          protected function 
      getFileManager()
          {
              return 
      $this->getInjection('fileManager');
          }

          protected function 
      getConfig()
          {
              
      // in config we can store storage credentials
              
      return $this->getInjection('config');
          }

          public function 
      unlink(Attachment $attachment)
          {
              
      // removing file, returns true or false
          
      }

          public function 
      isFile(Attachment $attachment)
          {
              
      // checks whether file exists
          
      }

          public function 
      getContents(Attachment $attachment)
          {
              
      // returns contents of the file
          
      }

          public function 
      putContents(Attachment $attachment$contents)
          {
              
      // stores contents of the file
          
      }

          public function 
      getLocalFilePath(Attachment $attachment)
          {
              
      // returns local file path of copied temporary file to be able to download//
              // if user wants to download the file we need to have it copied on the server as a temporary file
              // maybe this can be improved in future
          
      }

          public function 
      getDownloadUrl(Attachment $attachment)
          {
              
      // if there is a direct url to download; likely, leave this method empty
          
      }

          public function 
      hasDownloadUrl(Attachment $attachment)
          {
              
      // whether there is a url for download; likely return false;
          
      }
      }
      Don't forget to clear cache after changes in metadata.

      You can use $attachment->id for filenames on the storage

      I'm very busy these days. Don't have time to try to make this implementation.
      Last edited by yurikuzn; 03-14-2017, 03:37 PM.

      Comment


      • #19
        Hi, Did anyone completed the AWS S3 implementation by any chance ? Regards,

        Comment


        • #20
          I'm very curious about this as well. Being able to upload and download files to S3 would be a huge upgrade to local file storage. It would truly make EspoCRM highly available since the front end could be clustered. This would also be a necessity for Docker containers.

          Comment


          • #21
            HI!

            I have a good news and another bad news ...
            The good new:
            I have managed to put the s3 and it works perfectly: D: D

            The bad new:
            It only works for me in EspoCrm 4.7 I've tried to do the same configuration in 5.5, 5.4 and I can't get it to work.

            Is there a change in the FileStorage? What I can do?

            When has it functional I will upload the files in case I can help someone
            Thank you so much!

            Comment


            • #22
              Originally posted by dabasystem View Post
              HI!

              I have a good news and another bad news ...
              The good new:
              I have managed to put the s3 and it works perfectly: D: D

              The bad new:
              It only works for me in EspoCrm 4.7 I've tried to do the same configuration in 5.5, 5.4 and I can't get it to work.

              Is there a change in the FileStorage? What I can do?

              When has it functional I will upload the files in case I can help someone
              Thank you so much!
              This would be absolutely amazing if we can get it to work in 5.5+. Storing files on S3 would completely change my backup and recovery strategy for the better.

              Comment


              • #23
                In the company that we work, we have developed it. You can contact us by email, I guess there will be no problem!
                cau@dabasystem.com

                Comment


                • #24
                  Originally posted by dabasystem View Post
                  In the company that we work, we have developed it. You can contact us by email, I guess there will be no problem!
                  cau@dabasystem.com
                  Hi
                  can you share the code?

                  Comment

                  Working...
                  X