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上的數據。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章