seblucas / cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
1.43k stars 229 forks source link

external storage on remote webserver? (failed coding attempt) #506

Open OhSoGood opened 3 years ago

OhSoGood commented 3 years ago

Hi, My local COPS server is working (great! Thanks to all devs!). Now I'd like to get this setup: one server, hosting php code + database + thumbnails, accessing all ebooks and images from a remote static web server (typically a S3 storage).

Can anybody help? Or would even anybody kindly implement this for me (and many others that would enjoy benefiting from S3 cheap storage)? I'm a real newbee with PHP , and I tried what I could... Would it be interested to include that feature in the main branch of the project?

Reading through the code (I am a programmer but not in PHP), I had the feeling that very few things would need to be changed:

  1. I added a $config['external_storage'] = 'https://mys3torage.com/mybucket' in config_local.php

  2. In __construct in Book.php, I changed this:

    // Old code line 117:
    // $this->path = $config['external_storage'] . $line->path;
    // New code:
    if (empty($config['external_storage'])) {
        $this->path = Base::getDbDirectory() . $line->path;
    } else {
        $this->path = $config['external_storage'] . $line->path;
    }

    And

    // Old code line 130:
        // if (!file_exists($this->getFilePath('jpg'))) {
    // New code:
        if (empty($config['external_storage']) && !file_exists($this->getFilePath('jpg'))) {
  3. I ensured in my php.ini that allow_url_fopen=1 so that in Book.php GetImageSize and imagecreatefromjpeg (both in getThumbnail) would work.

The site is still working on my remote server, but I got no thumbnail at all. Like if I had changed nothing (and I did clear the cache :) )

Thanks in advance!

marioscube commented 3 years ago

Don't know anything about S3-storage or PHP programming, but you could:

Should be possible with Linux and Windows as a server.

OhSoGood commented 3 years ago

Thanks for the tips, but pitifully I only have non-root access on that Linux server, so I cannot mount any filesystem.

I can run my own services and cron jobs, but all with regular user rights

Le 08/09/2021 à 15:21, marioscube a écrit :

Don't know anything about S3-storage or PHP programming, but you could:

  • mount the S3-storage as a volume on your server and point COPS to that mountpoint.
  • use webDAV. Use webDAV mount on your server and point COPS to that mountpoint.

Should be possible with Linux and Windows as a server.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seblucas/cops/issues/506#issuecomment-915233770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANZVSQURXBCKWDK4PNQFD3UA5PM3ANCNFSM5DJUHHXA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mikespub commented 4 months ago

Included in release 2.7.1 at https://github.com/mikespub-org/seblucas-cops