`

Amazon Simple Storage Service(Amazon S3) 之一,基本概念

阅读更多


这2天接触了一下Amazon Web Services(AWS)中的Amazon Simple Storage Service,简称Amazon S3(下称S3)。S3站点上用下面的语句描述了自己的作用:

    Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.

通过S3这个接口,您可以把Amazon的存储服务当作一个硬盘,可以随时随地上传,下载数据,不过您得付钱才可以使用,即使您只是准备测试一下。S3首页上有价格表。在S3注册并付费获取2个数:Access Key ID和Secret Access Key,才可以使用S3的服务,因为所有的操作都需要这2个数进行身份验证。

一、基本概念:Buckets,Objects,Keys,Operations

注册后,用户通过名为bucket的容器来管理所有数据,这些数据称之为对象(Object)。比如,一个名为20071211/logo-320x240.gif的对象存放在livebaby这个bucket里,则可以通过URL:http: //s3.amazonaws.com/livebaby/20071211/logo-320x240.gif来访问这个对象。bucket有3个基本概念:1、不能删除非空的bucket;2、bucket不能转让给其他用户;3、每个用户最多只能有100个buckets。简单的说,bucket类似硬盘分区中的第一层目录。

这里还有一个key的概念,key是bucket中对象的唯一标识符,每个对象对应一个key。上例中,20071211/logo-320x240.gif称为key。

每个对象都有一组键值对,称为MetaData,分2种,系统metadata和 用户metadata。S3不处理用户metadata,只接收、存储、返回给用户,由用户自己处理。REST下,系统metadata以x-amz-开头,用户metadata以x-amz-meta-开头。

Amazon提供2种API:Simple Object Access Protocol(SOAP)和Representational State Transfer(REST)来访问AWS。这里一篇文章,其中简单对比了一下2者的区别,区别后总结说:“ In fact, you can think of REST as a kind of data-access methodology whereas SOAP is a process-control methodology.”

通过SOAP和REST,最常用的操作(Operation)有这么几个:

    * 创建bucket;
    * 上传对象,上传时必须指定一个key,同时还可以设置这个对象的访问控制权限,默认是私有的;
    * 下载对象,有HTTP 和 BitTorrent2种方式;
    * 删除对象;
    * 列表对象;列表时,可以通过一个前缀(prefix)来过滤显示不同的对象。

通过向AWS的服务端点(endpoint,http://s3.amazonaws.com/)发出PUT、GET、DELETE、HEAD等HTTP Requests,便可以操作S3上的数据。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics