Browse code

* s3cmd, S3/S3.py, S3/Config.py: Added --reduced-redundancy switch for Reduced Redundancy Storage.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@411 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2010/05/20 21:01:01
Showing 4 changed files
... ...
@@ -1,3 +1,8 @@
1
+2010-05-21  Michal Ludvig  <mludvig@logix.net.nz>
2
+
3
+	* s3cmd, S3/S3.py, S3/Config.py: Added --reduced-redundancy
4
+	  switch for Reduced Redundancy Storage.
5
+
1 6
 2010-05-20  Michal Ludvig  <mludvig@logix.net.nz>
2 7
 
3 8
 	* s3cmd, S3/ACL.py, S3/Config.py: Support for --acl-grant
... ...
@@ -73,6 +73,7 @@ class Config(object):
73 73
 	encoding = "utf-8"
74 74
 	urlencoding_mode = "normal"
75 75
 	log_target_prefix = ""
76
+	reduced_redundancy = False
76 77
 
77 78
 	## Creating a singleton
78 79
 	def __new__(self, configfile = None):
... ...
@@ -255,6 +255,8 @@ class S3(object):
255 255
 		headers["content-type"] = content_type
256 256
 		if self.config.acl_public:
257 257
 			headers["x-amz-acl"] = "public-read"
258
+		if self.config.reduced_redundancy:
259
+			headers["x-amz-storage-class"] = "REDUCED_REDUNDANCY"
258 260
 		request = self.create_request("OBJECT_PUT", uri = uri, headers = headers)
259 261
 		labels = { 'source' : unicodise(filename), 'destination' : unicodise(uri.uri()), 'extra' : extra_label }
260 262
 		response = self.send_file(request, file, labels)
... ...
@@ -286,6 +288,8 @@ class S3(object):
286 286
 		headers['x-amz-metadata-directive'] = "COPY"
287 287
 		if self.config.acl_public:
288 288
 			headers["x-amz-acl"] = "public-read"
289
+		if self.config.reduced_redundancy:
290
+			headers["x-amz-storage-class"] = "REDUCED_REDUNDANCY"
289 291
 		# if extra_headers:
290 292
 		# 	headers.update(extra_headers)
291 293
 		request = self.create_request("OBJECT_PUT", uri = dst_uri, headers = headers)
... ...
@@ -1597,6 +1597,7 @@ def main():
1597 1597
 	optparser.add_option(      "--rinclude-from", dest="rinclude_from", action="append", metavar="FILE", help="Read --rinclude REGEXPs from FILE")
1598 1598
 
1599 1599
 	optparser.add_option(      "--bucket-location", dest="bucket_location", help="Datacentre to create bucket in. Either EU or US (default)")
1600
+	optparser.add_option(      "--reduced-redundancy", "--rr", dest="reduced_redundancy", action="store_true", help="Store object with 'Reduced redundancy'. Lower per-GB price. [put, cp, mv]")
1600 1601
 
1601 1602
 	optparser.add_option(      "--log-target-prefix", dest="log_target_prefix", help="Target prefix for access logs (S3 URI)")
1602 1603