Announcement

Collapse
No announcement yet.

Filesystem Abstraction for PHP

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

  • Filesystem Abstraction for PHP

    Hello,
    really this is a good think ...
    many adapter exist (onedrive..)... if some one can make a extension.. i think is goal like Zlatan Ibrahimović


  • #2
    It's not big deal. Espo ready to customize filestorage. We have already done this for client internal custom file storage system based on mongoDB (REST API)

    Comment


    • #3
      Reading the website, it seem to do many thing more than just file storage, it like an external library connector or manager. So it seem like a good add-on capability to further extend EspoCRM if feature get accepted.

      Comment


      • #4
        Hello,
        i am not specialist.. but i think this library is "Yuri Mind"
        i have read many espocrm user ask for store file to another system
        i love this library because many adapter.. so i imagine :
        a very fast VPS with 10GB of space for sample... and store all "file/pdf/..." to a cloud system..
        then imagine .. 2 espocrm work like "cluster" .. with one storage place... Yuri can do that

        or simply have a backup of file on cloud or ... there are many adapter (azure/webdav/googledrive/... )

        Comment


        • #5
          We already have an interface for file storing: https://github.com/espocrm/espocrm/b...es/Storage.php

          Not sure if it's a good idea to get rid of the existing framework in favor of another. As an option is to create FileStorage engine 'flysystem' and then have separate configuration for it with the possibility to utilize different adapters. Those adapters require using composer to install so some knowledge is required to add implementations of specific services.

          Or create multiple FileStorage engines in espo, each one will utilize flyststem but different adapters.
          Last edited by yuri; 02-04-2021, 08:44 PM.

          Comment


          • esforim
            esforim commented
            Editing a comment
            If it require composer then I probably withdraw my interest. Composer isn't found in most Shared Hosting package.

          • yuri
            yuri commented
            Editing a comment
            It's possible to pull this off w/o composer for sure but this way will require manual updating in future and some knowledge how to deal with autoloading in PHP.

          • yuri
            yuri commented
            Editing a comment
            I will consider adding the lib into Espo, but no guarantees at this moment. We won't add all existing adapters for sure. So one will need to create an extension to have some 3rd party adapter.

        • #6
          Hello,

          for some one need to use this library :
          i use it for get big file from SFTP ... but why not make backup of espoCRM to remote SFTP or another adapter.
          here sample


          PHP Code:

          <?php

          namespace Espo\Custom\Jobs;

          use 
          Espo\Core\ORM\{
          Entity,
          EntityManager,
          ServiceFactory,
          Jobs\Job,
          };

          use 
          League\Flysystem\{
          Filesystem,
          PhpseclibV2\SftpConnectionProvider,
          PhpseclibV2\SftpAdapter,
          UnixVisibility\PortableVisibilityConverter,
          };

          class 
          SftpJobs extends \Espo\Core\Jobs\Base
          {
          public function 
          run()
          {
          $em $this->getEntityManager();
          $integration $em->getEntity('Integration''sftp');

          $filesystem = new Filesystem(
          new 
          SftpAdapter(
          new 
          SftpConnectionProvider(
          $integration->get('host'), // host (required)
          $integration->get('login'), // username (required)
          $integration->get('password'), // password (optional, default: null) set to null if privateKey is used
          null// private key (optional, default: null) can be used instead of password, set to null if password is set
          null// passphrase (optional, default: null), set to null if privateKey is not used or has no passphrase
          $integration->get('port'), // port (optional, default: 22)
          false// use agent (optional, default: false)
          30// timeout (optional, default: 10)
          3// max tries (optional, default: 4)
          null// host fingerprint (optional, default: null),
          null// connectivity checker (must be an implementation of 'League\Flysystem\PhpseclibV2\ConnectivityChecker' to check if a connection can be established (optional, omit if you don't need some special handling for setting reliable connections)
          ),
          '/'// root path (required)
          PortableVisibilityConverter::fromArray([
          'file' => [
          'public' => 0640,
          'private' => 0604,
          ],
          'dir' => [
          'public' => 0740,
          'private' => 7604,
          ],
          ])
          ));

          $path "/home/data/";
          $fileDate date('Y-n'strtotime(date('Y-m')." -1 month"));
          $fileName "file-" .$fileDate .".csv";
          $file $path .$fileName;

          if (
          $filesystem->fileExists($file))
          {
          $content $filesystem->read($file);
          file_put_contents 'data/data.csv' $content);
          $filesystem->move($file$path .'Backup/' .$fileName, [] );

          }

          return 
          true;

          }
          }

          Comment


          • #7
            Hello,

            Yuri have implemented this library.. incredible. thanks to him for find my find my feature request good
            Hope. . other can make new extension for webdav (nextcloud or .. ) ..
            Regards

            Comment


            • esforim
              esforim commented
              Editing a comment
              I see that he added ASW S3 storage, which is Amazon? https://github.com/espocrm/espocrm/issues/1934

              Where did he add SFTP, which you did?

            • item
              item commented
              Editing a comment
              Hello esforim,

              he add for Amazon.. now a good developper (not as me) have sample
              i can try to reproduce what Yuri have do. .for sftp.. but no result garanti

          • #8
            I didn't implement the library. I don't see a use for it in EspoCRM globally. I just utilized it for AWS S3 storage. Actually, I think about getting rid of the lib and utilize S3 Client directly. We don't need the adapter in EspoCRM. Moreover flysystem does not support PSR Stream Interface unfortunately.

            We have an interface for attachment storage. Utilizing any existing library is not a problem for a developer at this moment. Whether to use flysystem or not it's up to a developer.
            Last edited by yuri; 03-04-2021, 07:22 AM.

            Comment

            Working...
            X