Laravel和AWS Cloudfront [英] Laravel and AWS Cloudfront

查看:91
本文介绍了Laravel和AWS Cloudfront的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究和阅读关于一个特定主题的许多文章,但是在任何地方都找不到相关的答案.

I was researching and read a lot of articles on one specific topic but couldn't find relevant answers anywhere.

但是,我在Laravel中做一个有趣/私人的项目,我想使用Amazon S3存储.我已经完成所有设置,并且可以正常工作,我可以使用Laravel Filesystem从我的应用程序将图像上传到S3,但是我想做的是使用CloudFront(我也已经完成设置并可以工作,cloudfront是正确提供文件)以提供图像和文件.

However I'm doing some things as a fun/private project in Laravel and I wanted to use Amazon S3 storage. I have everything set up, and it's working, I'm able to upload images to S3 from my application using Laravel Filesystem, but what I'm trying to do is use CloudFront (I have this set up and working too, the cloudfront is serving files properly) for serving images and files.

现在我的问题是:如何将AWS CloudFront"URL"集成到Laravel中?我的意思是如何在Laravel应用程序中存储CloudFront网址?如何检索文件的URL(即图像),以便可以在应用程序中显示它.我是否仅将文件路径存储在数据库中并使用某种特定方式"提供完整的URL,还是将完整的AWS CloudFront URL保存在数据库中?

Now my question is: How to integrate AWS CloudFront "urls" into Laravel? I mean how to store CloudFront urls inside a Laravel application? How do I retrieve file urls (ie images) so I can display it inside my application. Do I store just file paths in a database and use "some specific way" to serve the full url or do I save the full AWS CloudFront urls in a database?

这是怎么工作的?抱歉,如果这个问题很愚蠢,但是我刚刚进入Laravel,在那里我还很新.

How does this works at all? Sorry if the question is stupid, but I just dived into Laravel and I'm pretty new there.

推荐答案

在config/filesystems/s3中将URL设置为您的云端URL

Set url to your cloudfront url in config/filesystems/s3

's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => 'http://xxx.cloudfront.net']

它适用于L5.5

这篇关于Laravel和AWS Cloudfront的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆