Kirby 3 and Amazon S3?

Is it possible to work with Amazon S3 to stock large images in combination with Kirby 3?

@texnixe, thanks for the link!
In my case i think i have to use a file create hook to upload the file to amazon or whatever and once the upload succeeded, replace the actual file on the disk with a resized version. In the website then i can use the resized version and when i want to show the image really big, then i can use the amazon file. But is there in the docs an example of how i can do this in kirby3? Thank you very much!

No, there isn’t. But then uploading to an external service is rather a question of using their API to upload stuff?

Might be an idea for a cookbook recipe, or a plugin.

In kirby 2 i used a code like this.

// SHRINK LARGE IMAGES ON UPLOAD
kirby()->hook('panel.file.upload', 'shrinkImage');
kirby()->hook('panel.file.replace', 'shrinkImage');
function shrinkImage($file, $maxDimension = 2000) {
    try {
        if ($file->type() == 'image' and ($file->width() > $maxDimension or $file->height() > $maxDimension)) {
            $originalPath = $file->dir().'/'.$file->filename();
            $resized = $file->resize($maxDimension,$maxDimension);
            $resizedPath = $resized->dir().'/'.$resized->filename();
            copy($resizedPath, $originalPath);
            unlink($resizedPath);
        }
    } catch(Exception $e) {
        return response::error($e->getMessage());
    }
}

Can this be used in Kirby 3 perhaps with some changes?

Oh, you meant the auto-shrinking on upload, there’s a plugin for that: https://github.com/texnixe/kirby-plugins/issues/623

1 Like

@texnixe, yes that’s what i needed! I check later how i can stream the original picture to amazon. I guess that must be possible in some way!

Thanks texnixe for your response. It’s useful.