/// <summary> /// Set a bucket's canned ACL /// </summary> /// <param name="bucket">Name of bucket to set canned ACL</param> /// <param name="acl">Canned ACL to set</param> public void SetBucketAcl(string bucket, Acl acl) { var request = new RestRequest(bucket + "?acl", Method.PUT); request.AddHeader("x-amz-acl", acl.ToString()); var response = client.Execute(request); if (!HttpStatusCode.OK.Equals(response.StatusCode)) { throw ParseError(response); } }
/// <summary> /// Create a bucket with a given name and canned ACL /// </summary> /// <param name="bucket">Name of the new bucket</param> /// <param name="acl">Canned ACL to set</param> public void MakeBucket(string bucket, Acl acl) { var request = new RestRequest("/" + bucket, Method.PUT); CreateBucketConfiguration config = new CreateBucketConfiguration(this.region); request.AddHeader("x-amz-acl", acl.ToString()); request.AddBody(config); var response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return; } throw ParseError(response); }
/// <summary> /// Create a bucket with a given name and canned ACL /// </summary> /// <param name="bucket">Name of the new bucket</param> /// <param name="acl">Canned ACL to set</param> public void MakeBucket(string bucket, Acl acl) { var request = new RestRequest("/" + bucket, Method.PUT); request.AddHeader("x-amz-acl", acl.ToString()); // ``us-east-1`` is not a valid location constraint according to amazon, so we skip it // Valid constraints are // [ us-west-1 | us-west-2 | EU or eu-west-1 | eu-central-1 | ap-southeast-1 | ap-northeast-1 | ap-southeast-2 | sa-east-1 ] if (this.region != "us-east-1") { CreateBucketConfiguration config = new CreateBucketConfiguration(this.region); request.AddBody(config); } var response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return; } throw ParseError(response); }