使用AWS S3的照片存储 [英] Using AWS S3 for photo storage

查看:570
本文介绍了使用AWS S3的照片存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用S3来存储用户上传的照片。很显然,我不会成为服务于图像文件的用户代理没有调整下来。然而,并不是一种尺寸会做,因为一些缩略图会比其他的大previews小。所以,我在想制作一套标准尺寸的缩放比例从最低的16×16的一些最高1024×1024的。这是解决这个问题的好办法?如果我需要一个新的规模以后?你将如何解决这个问题?

I'm going to be using S3 to store user uploaded photos. Obviously, I wont be serving the image files to user agents without resizing them down. However, not one size would do, as some thumbnails will be smaller than other larger previews. So, I was thinking of making a standard set of dimensions scaling from the lowest 16x16 to some highest 1024x1024. Is this a good way to solve this problem? What if I need a new size later on? How would you solve this?

推荐答案

pre-产生不同大小和它们存储在S3是一个罚款的做法,特别是如果你知道什么大小你需要的,很可能会使用所有的大小为所有影像,并没有那么多的图像和大小,存储成本过高。

Pre-generating different sizes and storing them in S3 is a fine approach, especially if you know what sizes you need, are likely to use all of the sizes for all of the images, and don't have so many images and sizes that the storage cost is excessive.

下面是我用的时候我不想pre-生成并存储所有不同尺寸的每一个形象的另一种方法,或者当我不知道是什么尺寸,我会想在未来使用方法:

Here's another approach I use when I don't want to pre-generate and store all the different sizes for every image, or when I don't know what sizes I will want to use in the future:

  1. 存储在S3原来的大小。

  1. Store the original size in S3.

运行一个Web服务器,它可以生成要求原始图像的任何所需的大小。

Run a web server that can generate any desired size from the original image on request.

在Web服务器前面坚持一个CDN(CloudFront的)。

Stick a CDN (CloudFront) in front of the web server.

现在,你的网站或应用程序可以请求就像从CloudFront的/16x16/someimage.jpg的URL。第一次遇到这种情况,CloudFront的将得到调整后的图像从你的Web服务器,但随后CloudFront的将缓存的形象和服务给你,大大减少交通击中Web服务器的数量。

Now, your web site or application can request a URL like /16x16/someimage.jpg from CloudFront. The first time this happens, CloudFront will get the resized image from your web server, but then CloudFront will cache the image and serve it for you, greatly reducing the amount of traffic that hits your web server.

下面是需要改变的图像从任意URL,通过CloudFront的为他们提供服务的一个服务: http://filter.to

Here's a service that resizes images from arbitrary URLs, serving them through CloudFront: http://filter.to

这篇关于使用AWS S3的照片存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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