如何在Laravel中使用缩略图并将其存储在AWS S3存储桶中

时间:2022-09-28 10:47:59

I need to implement convenient way to create thumbnails into Laravel Framework. But I want to store everything on Amazon S3. I checked this package https://github.com/Folkloreatelier/laravel-image but it doesn't have possibility to store cache of thumbnails on s3. I checked http://symfony.com/doc/current/bundles/LiipImagineBundle/index.html but it works good with Symfony and I don't know if it will work easy with Laravel. Do you have any experience in solving such problems?

我需要实现在Laravel Framework中创建缩略图的便捷方法。但我想将所有内容存储在Amazon S3上。我检查了这个包https://github.com/Folkloreatelier/laravel-image,但它没有可能在s3上存储缩略图缓存。我检查了http://symfony.com/doc/current/bundles/LiipImagineBundle/index.html,但它与Symfony一起工作很好,我不知道它是否适用于Laravel。你有解决这些问题的经验吗?

1 个解决方案

#1


1  

I think the easiest solution is to use Intervention.

我认为最简单的解决方案是使用干预措施。

$image = Image::make($file)->resize($width, $height)->save();

and then you just do the standard s3->put and store the path into your database.

然后你只需要执行标准的s3-> put并将路径存储到数据库中。

$s3->put($path, $image->__toString(), 'public');
$url = $this->s3->url($path);

I didn't thoroughly read through this but it might give you some more insight on how to use Intervention.

我没有仔细阅读过这篇文章,但它可能会让您对如何使用干预有更深入的了解。

#1


1  

I think the easiest solution is to use Intervention.

我认为最简单的解决方案是使用干预措施。

$image = Image::make($file)->resize($width, $height)->save();

and then you just do the standard s3->put and store the path into your database.

然后你只需要执行标准的s3-> put并将路径存储到数据库中。

$s3->put($path, $image->__toString(), 'public');
$url = $this->s3->url($path);

I didn't thoroughly read through this but it might give you some more insight on how to use Intervention.

我没有仔细阅读过这篇文章,但它可能会让您对如何使用干预有更深入的了解。