From 4a04bd2764a065140568efeef29c43d349fa6281 Mon Sep 17 00:00:00 2001 From: "mooredan@suncup.net" Date: Mon, 18 Oct 2010 22:35:14 +0000 Subject: [PATCH] Fixed issue #89 - Support for Reduced Redundancy with a patch from chregu's code stream Tested the use_rrs=1 option and confirmed that the files in the bucket are being tagged as using RRS through Amazon's AWS cockpit git-svn-id: http://s3fs.googlecode.com/svn/trunk@200 df820570-a93a-0410-bd06-b72b767a4274 --- s3fs/s3fs.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/s3fs/s3fs.cpp b/s3fs/s3fs.cpp index 90c2c25..30a63be 100644 --- a/s3fs/s3fs.cpp +++ b/s3fs/s3fs.cpp @@ -351,6 +351,8 @@ static string service_path = "/"; // if .size()==0 then local file cache is disabled static string use_cache; +static string use_rrs; + // private, public-read, public-read-write, authenticated-read static string default_acl("private"); @@ -712,6 +714,10 @@ put_headers(const char* path, headers_t meta) { headers.append(key+":"+value); } + if (use_rrs.substr(0,1) == "1") { + headers.append("x-amz-storage-class:REDUCED_REDUNDANCY"); + } + headers.append("Authorization: AWS "+AWSAccessKeyId+":"+calc_signature("PUT", ContentType, date, headers.get(), resource)); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.get()); @@ -776,6 +782,10 @@ put_local_fd(const char* path, headers_t meta, int fd) { headers.append(key+":"+value); } + if (use_rrs.substr(0,1) == "1") { + headers.append("x-amz-storage-class:REDUCED_REDUNDANCY"); + } + headers.append("Authorization: AWS "+AWSAccessKeyId+":"+calc_signature("PUT", ContentType, date, headers.get(), resource)); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.get()); @@ -1653,6 +1663,10 @@ my_fuse_opt_proc(void *data, const char *arg, int key, struct fuse_args *outargs use_cache = strchr(arg, '=') + 1; return 0; } + if (strstr(arg, "use_rrs=") != 0) { + use_rrs = strchr(arg, '=') + 1; + return 0; + } if (strstr(arg, "host=") != 0) { host = strchr(arg, '=') + 1; return 0;